如果我在列中添加小部件,则该列的顶部将向上。(图2)
图片1
Column(
crossAxisAlignment: CrossAxisAlignment.center
mainAxisAlignment: MainAxisAlignment.center
children: <Widget>[
Text("Test1")
]
)
picture2
Column(
crossAxisAlignment: CrossAxisAlignment.center
mainAxisAlignment: MainAxisAlignment.center
children: <Widget>[
Text("Test1"),
Text("Test2")
]
)
答案 0 :(得分:1)
从上面的图片重新创建了您想要的:
制作两个Expanded
小部件,然后让第二个Expanded
小部件放入Column
,在其中放置Text
s小部件:
return Scaffold(
body: Column(
children: [
Expanded(
child: SizedBox(),
),
Expanded(
child: SizedBox.expand(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Test 1',
style: TextStyle(
fontSize: 20,
color: Colors.red,
),
),
Text(
'Test 2',
style: TextStyle(
fontSize: 20,
color: Colors.red,
),
),
Text(
'Test 3',
style: TextStyle(
fontSize: 20,
color: Colors.red,
),
),
],
),
),
),
],
),
);
答案 1 :(得分:-1)
使用 mainAxisAlignment:MainAxisAlignment.start