Keyboard not being detected. MediaQuery.of(context).viewInsets.bottom always returns 0.0

后端 未结 3 536
感动是毒
感动是毒 2021-02-09 03:45

I have a scaffold with a TextField inside. The keyboard always covers this field when it previously would move the field above the keyboard. This is happening on all the pages i

3条回答
  •  长发绾君心
    2021-02-09 04:21

    In case of complicated widget tree MediaQuery.of(context).viewInsets.bottom gives null even if the keyboard is open. So, we have to mutate values down the tree.

    This package gives simple in use provider for getting info down the tree https://pub.dev/packages/flutter_keyboard_size

    Or, you can mutate info about keyboard size down the tree by yourselves (you can look the code in the package).

提交回复
热议问题