button - 如何在 Flutter 中为 Button 设置边距

标签 button flutter margin flutter-layout

我只是在 Flutter 中创建一个表单。我无法设置按钮的上边距。

class _MyHomePageState extends State<MyHomePage> {

String firstname; 
String lastname;
final scaffoldKey = new GlobalKey<ScaffoldState>();
final formKey = new GlobalKey<FormState>();


    @override
  Widget build(BuildContext context) {
    return new Scaffold(
      key: scaffoldKey,
      appBar: new AppBar(
        title: new Text('Validating forms'),
      ),
      body: new Padding(
        padding: const EdgeInsets.all(16.0),
        child: new Form(
          key: formKey,
          child: new Column(
            children: [
              new TextFormField(
                decoration: new InputDecoration(labelText: 'First Name'),
                validator: (val) =>
                    val.length == 0 ?"Enter FirstName" : null,
                onSaved: (val) => firstname = val,
              ),
              new TextFormField(
                decoration: new InputDecoration(labelText: 'Password'),
                validator: (val) =>
                    val.length ==0 ? 'Enter LastName' : null,
                onSaved: (val) => lastname = val,
                obscureText: true,
              ),
              new RaisedButton(
                onPressed: _submit,
                child: new Text('Login'),
              ),
            ],
          ),
        ),
      ),
    );
  }

最佳答案

将您的按钮放入 Container然后设置边距

Container(
    margin: const EdgeInsets.only(top: 10.0),
    child : RaisedButton(
                onPressed: _submit,
                child: Text('Login'),
              ),

关于button - 如何在 Flutter 中为 Button 设置边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50186555/

相关文章:

css - 交错文本和按钮的问题

javascript - svg 中的 <button> 元素?

Flutter,访问父容器widget的padding值

css - 负上边距不适用于子图像

javascript - 如何浏览图片并在浏览器中显示?

firebase - Firebase Flutter 应用程序是否有办法在离线应用程序重新启动时保留数据?

flutter - 在 Flutter 中,什么时候你更喜欢 `Widget` 继承而不是组合?

css - 用单杠去掉右边多余的空格?

css - HTML Dreamweaver 左边距

css - 悬停时无法更改按钮