知识FlutterFlutter-弹性布局
Kahvia
Flex
- direction(主轴方向)
- mainAxisAlignment(主轴对齐方式)
- crossAxisAlignment(交叉轴对齐方式)
- textDirection(水平方向上的排列顺序)
- verticalDirection(垂直方向上的排列顺序)
- children(子组件)
Expended(可伸缩组件,放在弹性布局组件中)
- flex(声明弹性布局所占比例)
- child(子组件)
代码区
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| class MyPage extends StatelessWidget { const MyPage({Key? key}) : super(key: key);
@override Widget build(BuildContext context) { return Flex( direction: Axis.horizontal, textDirection: TextDirection.rtl, crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( flex: 2, child: Container( color: Colors.orange, height: 60, child: const Icon(Icons.settings,size: 40,), ), ), Expanded( flex: 1, child: Container( color: Colors.lightBlue, height: 40, child: const Icon(Icons.ice_skating,size: 40,), ), ), ], ); } }
|