button - 如何在 Flutter 中为 Button 设置边距
问题描述
我只是在 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'),
),
],
),
),
),
);
}
解决方案
将您的按钮放入容器中,然后设置边距
new Container(
margin: const EdgeInsets.only(top: 10.0),
child : new RaisedButton(
onPressed: _submit,
child: new Text('Login'),
),
推荐阅读
- javascript - 无序字符串数组与 lodash 的比较
- node.js - 用于 e2e 前端测试的暂存后端
- android - 是否有可能知道哪个视图打开了警报视图?
- regex - 确保字符串不完全匹配的正则表达式
- xamarin.android - 如何在 Xamarin android 中实现线性渐变?
- ios - iOS - 在输入时验证用户 IP 地址
- python - 按子字符串聚合 json 元素
- mongodb - 如何为嵌入文档编写 mongo 查询
- sql - DB2 - 查询一次更新 10000 行
- postgresql - 将 CSV 文件数据导入 PostgreSQL 表自动化