sososdk / flash

⚡️A highly customizable, powerful and easy-to-use alerting library for Flutter.

Home Page:https://sososdk.github.io/flash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

when a Flash appears, it hides the keyboard

AymanProjects opened this issue · comments

commented

the forgot password will show a dialog on click. but it hides the keyboard.
It also happens when a snackbar appears.

untitled

commented

I modified the source code and it no longer hides the keyboard.
I just commented the unwanted code as shown in the image.
anyway this is not really elegant and the package is now stored locally with the my project files.
maybe you could make this feature optional ?
image

Hi @AymanProjects, Now the code is as expected. Maybe you need add autofocus: true in TextFormField or TextField.

Example:

    Form(
      child: TextFormField(
        controller: editingController,
        autofocus: true,
      ),
    )
commented

That solved the problem, Thanks ♥

I have the same issue, how to prevent interrupt the typing when Flash appears?
Any help is appreciated!

Hi @AymanProjects, Now the code is as expected. Maybe you need add autofocus: true in TextFormField or TextField.

Example:

    Form(
      child: TextFormField(
        controller: editingController,
        autofocus: true,
      ),
    )

@ming-chu example:

autofocus: true,

@sososdk Thanks for your reply.

Here is my case:
I use this lib for the top bar notification, maybe with frequency like 20 times/minutes.
when users typing and respond to the msg, this will interrupt the typing.

@ming-chu which one interrupt the typing?

@sososdk
I am developing a chat app. I use this lib for showing new message notifications.
When Flash appears, it blocks the entire screen with overlay and closes the keyboard.
The input will focus again after the Flash is finished, but the process of typing was interrupted which cannot keep typing when the Flash show up.

It was fine on flash: ^1.3.1

@ming-chu please show me the code about how to display the flash.

@sososdk Thanks for the reply and here is the code

showFlash(
  context: context,
  duration: const Duration(seconds: 2),
  persistent: true,
  builder: (_, controller) {
    return Flash(
      controller: controller,
      backgroundColor: Colors.white,
      brightness: Brightness.light,
      boxShadows: [BoxShadow(blurRadius: 4)],
      barrierBlur: 3.0,
      barrierColor: Colors.black38,
      barrierDismissible: true,
      behavior: FlashBehavior.floating,
      position: FlashPosition.top,
      child: FlashBar(
        title: Text('You have a new msg!'),
        content: Text('hello world~'),
      ),
    );
  },
);

@ming-chu try to set persistent: false .

after I set persistent: false it got an exception 🤔

E/flutter ( 5759): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: 'package:flash/flash.dart': Failed assertion: line 98 pos 14: 'overlay != rootOverlay': overlay can't be the root overlay when persistent is false
E/flutter ( 5759): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
E/flutter ( 5759): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter ( 5759): #2      new FlashController (package:flash/flash.dart:98:14)
E/flutter ( 5759): #3      showFlash (package:flash/flash.dart:25:10)

@ming-chu try to remove barrierBlur and barrierColor, and set persistent: true.

barrierBlur and barrierColor will block the behind view.

@ming-chu try to remove barrierBlur and barrierColor, and set persistent: true.

barrierBlur and barrierColor will block the behind view.

Thanks for the advice, I will try it👍

@sososdk
it works!!! Thank you very much!
You are my hero!