【发布时间】:2018-10-09 16:58:39
【问题描述】:
我想要 AppBar 居中后的所有内容。然而它不是居中的。 这就是我的代码的样子。如果有人能告诉我为什么我当前的代码没有将登录名放在密码项的中心,我将不胜感激。
这就是我当前的布局
这是我的代码
class MyScaffold extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Material is a conceptual piece of paper on which the UI appears.
return new Material(
// Column is a vertical, linear layout.
child: new Column(
children: <Widget>
[
new MyAppBar(
title: new Text('Example title', style: Theme
.of(context)
.primaryTextTheme
.title),
),
new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
new Text("Login"),
new TextField(
decoration: new InputDecoration(
border: new OutlineInputBorder(), hintText: '---')),
new Text("Password"),
new TextField(
decoration: new InputDecoration(
border: new OutlineInputBorder(), hintText: '---')),
]),
)
]
));
}
}
我希望它看起来像这样
我知道我可以通过展开来实现这种外观替换中心。为什么这行得通?两者有什么区别。谁能澄清 Expanded 的真正作用?
【问题讨论】:
-
它在我看来是居中的。
-
我刚刚更新了帖子。我想登录直到密码小部件垂直居中
标签: dart flutter flutter-layout