正常情况
键盘打开时
它显示溢出错误
当resizeToAvoidBottomInset
包括在内
TextField隐藏在键盘下方
码:
void main() => runApp(MaterialApp(home: HomePage()));
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
// resizeToAvoidBottomInset: false, // including this hides TextField beneath Keyboard
body: Column(
children: <Widget>[
FlutterLogo(size: 500),
TextField(decoration: InputDecoration(hintText: " Enter something here ...")),
Expanded(child: FlutterLogo(size: 300)),
],
),
);
}
}
编辑:
我想要的是TextField
应该在它聚焦时自动向上滚动,这也意味着FlutterLogo1也应该向上滚动而FlutterLogo2应该在键盘下面。 (这在Android中是非常常见的行为,一切都是为你处理的)
我认为这会奏效。
void main() => runApp(MaterialApp(home: HomePage()));
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
// resizeToAvoidBottomInset: false, // including this hides TextField beneath Keyboard
body: Stack(
children: <Widget>[
FlutterLogo(size: 500),
Column(children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(0.0, 200.0, 0.0, 0.0),
child: TextField( decoration: InputDecoration(hintText: " Enter something here ..."))),
Expanded(child: FlutterLogo(size: 300)),
],)
],
),
);
}
}