Flutter - how to use ScrollView correctly when displaying the keyboard?
I've seen several videos on youtube about it but in my code it doesn't work like in the video. I've looked at some questions and some dirty using the code below, but it doesn't solve the problem.
Scaffold(
body: SingleChildScrollView(...),
...
I've tried using ListView
but I always have the same result.
The gif below illustrates what happens: when you open the keyboard the layout does not move up showing the text field.
I tried to use FocusNode
in TextField
but tbm doesn't work.
My code is it.
var itemlBorder = OutlineInputBorder(borderSide: BorderSide(color: MyTheme.tintColor()));
return Scaffold(
appBar: AppBar(title: Text('PageTitle')),
body: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Column(children: [
//Titulo
Container(
height: 50,
margin: EdgeInsets.only(top: 10),
padding: EdgeInsets.only(left: 10, right: 10, top: 7),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
color: MyTheme.tintColor()
),
child: TextField(
textInputAction: TextInputAction.next,
controller: _cTitulo,
keyboardType: TextInputType.name,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(12, 0, 12, 0),
enabledBorder: itemlBorder,
focusedBorder: itemlBorder,
labelText: 'Titulo'.toUpperCase(),
),
),
),
//Anexo
Container(...
...
]
)
)
0
Author: Jonas Ferreira, 2020-07-23
1 answers
I managed to solve this problem.
The problem is not in the code but in AndroidManifest.xml
.
I just added android:windowSoftInputMode="adjustResize"
to the tag activity
0
Author: Jonas Ferreira, 2020-07-27 14:40:17