Closed mateusfsilva closed 5 years ago
The issue is the Expanded
widget inside your Column
. That effectively gives the column infinite height. You can't have a widget of unbounded height inside a ScrollView
, which is what KeyboardAvoider
uses to scroll your content. Replace KeyboardAvoider
with SingleChildScrollView
and you'll get the same result. If you remove the Expanded
widget, it will work fine.
But KeyboardAvoider is meant to avoid the keyboard automatically when text fields get focus, am I right. In this post, https://medium.com/flutter-nyc/avoiding-the-on-screen-keyboard-in-flutter-ae0e46ecb96c you said we can use it instead of "Scaffold", if remove the scaffold widget, you will get an error that the "TextField" needs a wrapping Material widget.
Regarding your original issue, KeyboardAvoider
works by wrapping your content in a ScrollView
to make it scrollable. So your content has to play nice inside a ScrollView
, which means no widgets with unbounded height.
Re: your most recent comment: you can still use a Scaffold
for the other features it offers (app bar, drawer, etc.). Just set resizeToAvoidBottomInset
to false
. Or you can give your TextField
an explicit Material
ancestor widget.
Hi,
I have the following layout on a
CupertinoApp
and I am trying to add the keyboard_avoider to scroll theTextField
s.When I add the
KeyboardAvoider
widget I have the following error:I am using the following code to make the app.
Here is the
flutter doctor
result: