Flutter(60):Layout组件之UnconstrainedBox

Flutter教学目录持续更新中

Github源代码持续更新中

1.UnconstrainedBox介绍

消除约束的widget

2.UnconstrainedBox属性

  • child:
  • textDirection:
  • alignment = Alignment.center:
  • constrainedAxis:横向或者纵向保留约束

3.使用

这个我们在介绍LimitedBox组件的时候应用到过:Flutter(54):Layout组件之LimitedBox

      body: Container(
        width: double.infinity,
        height: double.infinity,
        constraints: BoxConstraints(
          minWidth: 200,
          minHeight: 200,
        ),
        child: UnconstrainedBox(
          // constrainedAxis: Axis.horizontal,
          alignment: Alignment.center,
          child: Container(
            width: 30,
            height: 30,
            color: Colors.blue,
          ),
        ),
      ),
image.png

我们还可以选择横向保留约束:constrainedAxis: Axis.horizontal

image.png

下一节:Layout组件之CustomSingleChildLayout

Flutter(61):Layout组件之CustomSingleChildLayout

Flutter教学目录持续更新中

Github源代码持续更新中

你可能感兴趣的:(Flutter(60):Layout组件之UnconstrainedBox)