Flutter 流式布局之Wrap

120 阅读1分钟

Wrap使用笔记

Wrap是一个可以使子控件自动换行的控件,默认的方向是水平的,使用起来也很简单。

首先看下他的构造方法:

Wrap({
    Key key,
    this.direction = Axis.horizontal,   //排列方向,默认水平方向排列
    this.alignment = WrapAlignment.start,  //子控件在主轴上的对齐方式
    this.spacing = 0.0,  //主轴上子控件中间的间距
    this.runAlignment = WrapAlignment.start,  //子控件在交叉轴上的对齐方式
    this.runSpacing = 0.0,  //交叉轴上子控件之间的间距
    this.crossAxisAlignment = WrapCrossAlignment.start,   //交叉轴上子控件的对齐方式
    this.textDirection,   //textDirection水平方向上子控件的起始位置
    this.verticalDirection = VerticalDirection.down,  //垂直方向上子控件的其实位置
    List<Widget> children = const <Widget>[],   //要显示的子控件集合
})