When using the Builder
widget, the parent's build method will construct a new tree of widgets so a new Builder
child will not be identified the outside context
of the keyboard --> do not know the keyboard change event --> height keyboard always returns 0.
Try to calculate availableHeight
out of Builder
widget:
Widget build(BuildContext context) {
double screenHeight = MediaQuery.sizeOf(context).height;
double keyboardHeight = MediaQuery.viewInsetsOf(context).bottom;
...
And use MediaQuery.viewInsetsOf
instead, this is new recommend docs.
P/S: This [video](https://youtu.be/ceCo8U0XHqw?si=yAyRxzUt6c_L2vnC show clearly the concept of viewInsets
,viewPadding
and padding