这是我的代码,我在 SingleChildScrollView 中添加了一些 TextFormField,并尝试在屏幕的底部中心放置一个按钮,不允许 Expend,FloatActionButton 会在输入文本时随键盘移动,有什么解决方案吗?
body: SafeArea(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const SizedBox(height: 24.0),
TextFormField(
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'tell me some detail',
helperText: 'description'
),
maxLines: 4,
maxLength: 200,
textInputAction: TextInputAction.done,
),
const SizedBox(height: 48.0),
TextField(
decoration: InputDecoration(
hintText: 'your name here',
helperText: 'name'
),
),
Flexible(
fit: FlexFit.loose,
child: RaisedButton(
onPressed: (){},
child: Text('Submit'),
),
)
],
),
),
),
最佳答案
试试这个
@override
Widget build(BuildContext context) {
return SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 24.0),
TextFormField(
decoration: InputDecoration(border: OutlineInputBorder(), hintText: 'tell me some detail', helperText: 'description'),
maxLines: 4,
maxLength: 200,
textInputAction: TextInputAction.done,
),
const SizedBox(height: 48.0),
TextField(decoration: InputDecoration(hintText: 'your name here', helperText: 'name')),
Spacer(),
RaisedButton(
onPressed: () {},
child: Text('Submit'),
)
],
),
),
);
}
关于flutter - 如何将按钮放置在屏幕的底部中央?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55038798/