dart - 如何用 Flutter 实现这种布局
问题描述
我完全不知道如何创建这个布局:
我的代码:
import 'package:flutter/material.dart';
class SignupScreen extends StatefulWidget {
final _username, _email, _password;
@override
_SignupScreenState createState() => new _SignupScreenState();
}
class _SignupScreenState extends State<SignupScreen> {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new Container(
padding: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new TextField(
keyboardType: TextInputType.emailAddress,
decoration: new InputDecoration(
hintText: 'Email'
)
),
new TextField(
obscureText: true,
decoration: new InputDecoration(
hintText: 'Password'
)
),
new RaisedButton(
onPressed: () {},
child: new Text('Sign In')
),
new FlatButton(
onPressed: () {},
child: new Text('Sign Up')
),
],
)
)
)
);
}
}
结果:
我如何FlatButton
在屏幕底部找到它?
解决方案
import 'package:flutter/material.dart';
void main() => runApp(
new MaterialApp(
debugShowCheckedModeBanner: false,
home: new HomePage(),
),
);
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => new _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Home'),
),
body: new Padding(
padding: const EdgeInsets.all(15.0),
child: new Column(
children: <Widget>[
new Expanded(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new TextField(
decoration: new InputDecoration(labelText: 'Username'),
),
new TextField(
decoration: new InputDecoration(labelText: 'Password'),
),
new Container(
padding: const EdgeInsets.only(top: 10.0),
width: double.infinity,
child: new RaisedButton(
onPressed: () {},
child: new Text('Login'),
),
),
],
),
),
new Container(
width: double.infinity,
child: new RaisedButton(
onPressed: () {},
child: new Text('Register'),
),
),
],
),
),
);
}
}
希望这可以帮助!
推荐阅读
- google-sheets - ARRAYFORMULA 不扩展
- python - 如何在 Python 中识别目录和子目录中的所有 .txt 文件?
- python - 如何正确地将基于向量的函数应用于熊猫数据框列?
- ldap - OpenLDAP ACL 不起作用 - 错误代码 50 - 没有对父级的写访问权
- javascript - 当我尝试在一个小括号中编写代码时,CodeSandBox 中的 CSS 语法错误
- swift - 快速将字符串转换为可执行代码
- github-actions - 是否可以在 Github Action 的名称中包含版本号?
- php - Foreach 等待
- compression - AWS Amplify 部署 - 使用压缩
- android - 优化 Android 中 Mapbox Navigation SDK 的电池使用情况