[英]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'))
)
]),
);
}
通過增加
邊距:new EdgeInsets.only(底部: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'))
)
]),
);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.