Flutter 组件 Row、Column、Expanded
xxxixxxx

Row

水平布局

1
2
3
4
5
6
7
8
9
ow(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MyIconWidget(Icons.tv, color: Colors.redAccent),
MyIconWidget(Icons.ac_unit, color: Colors.blueAccent),
MyIconWidget(Icons.access_alarms, color: Colors.orangeAccent)
],
),

Column

垂直布局

1
2
3
4
5
6
7
8
9
Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
MyIconWidget(Icons.tv, color: Colors.redAccent),
MyIconWidget(Icons.ac_unit, color: Colors.blueAccent),
MyIconWidget(Icons.access_alarms, color: Colors.orangeAccent)
],
),

Expanded

扩展组件 比例分配

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Expanded(
child: MyIconWidget(Icons.games, color: Colors.blueGrey),
),



Row(
children: [
Expanded(
flex: 2,
child: MyIconWidget(Icons.ac_unit, color: Colors.red),
),
Expanded(
flex: 1,
child: MyIconWidget(Icons.ac_unit, color: Colors.amberAccent),
),
Expanded(
flex: 2,
child: MyIconWidget(Icons.ac_unit, color: Colors.red),
),
],
);
  • Post title:Flutter 组件 Row、Column、Expanded
  • Post author:xxxixxxx
  • Create time:2020-12-29 10:20:00
  • Post link:https://xxxixxx.github.io/2020/12/29/400-Flutter组件Row、Column、Expanded/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments