Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does keyboardVisibilityController fire event when keyboard starts showing or on keyboard is fully shown? #122

Open
PavelTurk opened this issue Sep 17, 2022 · 0 comments

Comments

@PavelTurk
Copy link

I have a CustomScrollView which I need to scroll down when keyboard is shown. To detect when keyboard is shown I use the following code:

  late StreamSubscription<bool> keyboardSubscription;

  @override
  void initState() {
    super.initState();
    scrollController = new ScrollController();
    var keyboardVisibilityController = KeyboardVisibilityController();
    keyboardSubscription = keyboardVisibilityController.onChange.listen((bool visible) {
      if (visible) {
        Future.delayed(const Duration(milliseconds: 350), () {
          this.scrollToBottom();// here I scroll my CustomScrollView
        });
      }
    });
  }

As it seen I call this.scrollToBottom() with 350 ms delay because otherwise my CustomScrollView is not scrolled. So the question, when is keyboardVisibilityController.onChange.listen called? When keyboard is just starting showing or when keyboard is fully shown and ready for typing? Or could anyone explain why I need to use delay in my code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant