0%

flutter控件从上到下居中排列

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Column(
children: <Widget>[
Expanded(child:
Image.asset('assets/images/$imageName.png')
),

Text(
this.model.title,
style: TextStyle(
fontSize: 15,
color: Colors.white,
),
),
],
),

注解:

  • column是一个垂直的容器,子控件放在children里面
  • 要想让图片居中,需要放在expanded容器里面,官方定义:expanded is a widget that expands a child of a row,column,or flex so that the child fills the available space.
  • image