Flutter RaisedButton 覆盖 TextField
Flutter RaisedButton covering TextField
我的应用程序中有一个 TextField
,紧接着是一个 RaisedButton
。
当我输入 TextField
时,按钮会上移到我的键盘上方。如果我在 TextField
中一直向下滚动,我可以看到所有文本。但是,当我输入并转到新行时,它不会一直向下滚动,并且按钮会覆盖最后一行文本的一部分。
如何确保在我输入时整行文本始终可见?
理想情况下,我希望按钮在我打字时不在键盘上方,而是被它隐藏。
不过,如果它更容易,我也可以使用确保 TextField
一直向下滚动的解决方案。
这是我的应用程序的(简化的)相关部分:
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Title')),
body: new Column(children: <Widget>[
new Expanded(child: new Container(
child: new TextField(
maxLines: null,
controller: textController,
),
padding: new EdgeInsets.all(8.0),
)),
new RaisedButton(
onPressed: () => _myFunction(context),
child: new Center(child: new Text('Save'))
)
]),
);
}
通过添加
margin: new EdgeInsets.only(bottom: 50.0),
在展开的小部件中
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Title')),
body: new Column(children: <Widget>[
new Expanded(child: new Container(
margin: new EdgeInsets.only(bottom: 50.0),
child: new TextField(
maxLines: null,
controller: textController,
),
padding: new EdgeInsets.all(8.0),
)),
new RaisedButton(
onPressed: () => _myFunction(context),
child: new Center(child: new Text('Save'))
)
]),
);
}
我的应用程序中有一个 TextField
,紧接着是一个 RaisedButton
。
当我输入 TextField
时,按钮会上移到我的键盘上方。如果我在 TextField
中一直向下滚动,我可以看到所有文本。但是,当我输入并转到新行时,它不会一直向下滚动,并且按钮会覆盖最后一行文本的一部分。
如何确保在我输入时整行文本始终可见?
理想情况下,我希望按钮在我打字时不在键盘上方,而是被它隐藏。
不过,如果它更容易,我也可以使用确保 TextField
一直向下滚动的解决方案。
这是我的应用程序的(简化的)相关部分:
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Title')),
body: new Column(children: <Widget>[
new Expanded(child: new Container(
child: new TextField(
maxLines: null,
controller: textController,
),
padding: new EdgeInsets.all(8.0),
)),
new RaisedButton(
onPressed: () => _myFunction(context),
child: new Center(child: new Text('Save'))
)
]),
);
}
通过添加
margin: new EdgeInsets.only(bottom: 50.0),
在展开的小部件中
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: new Text('Title')),
body: new Column(children: <Widget>[
new Expanded(child: new Container(
margin: new EdgeInsets.only(bottom: 50.0),
child: new TextField(
maxLines: null,
controller: textController,
),
padding: new EdgeInsets.all(8.0),
)),
new RaisedButton(
onPressed: () => _myFunction(context),
child: new Center(child: new Text('Save'))
)
]),
);
}