flutter - 如何将按钮放置在屏幕的底部中央?

标签 flutter textfield

这是我的代码,我在 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'),
                ),
              )
            ],
          ),
        ),
      ),

Could I move the button at the right place

最佳答案

试试这个

@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'),
          )
        ],
      ),
    ),
  );
}

enter image description here

关于flutter - 如何将按钮放置在屏幕的底部中央?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55038798/

相关文章:

api - 我 flutter 的 Http 发布请求未发送表单数据

flutter - 在Flutter,Dart中将Map <String,Object>转换为List <Widget>

flutter - Flutter FlatButton内部空间

firebase - 单击推送通知时如何在我的 flutter 应用程序中打开特定页面

文本字段中的日期格式

jquery - 复选框和文本字段 jQuery

flutter - 如何在几秒钟后返回一个小部件?

algorithm - Xcode TextField显示数字,但是代码添加小数

macos - 更改插入符号的颜色 SwiftUI TextField MacOS

swift - 在文本字段中键入字符时 UI 元素移动