正常情况
打开键盘时
它显示溢出错误
包含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原生的非常普遍的行为,一切都由您处理)
答案 0 :(得分:0)
我认为这会起作用。
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)),
],)
],
),
);
}
}