Flutter教学

Flutter(57):Layout组件之SizedOverfl

2020-10-19  本文已影响0人  starryxp

Flutter教学目录持续更新中

Github源代码持续更新中

1.SizedOverflowBox介绍

一个特定大小的widget,但是会将它的原始约束传递给子控件,它可能会溢出。

2.SizedOverflowBox属性

3.Alignment

4.使用

image.png
          Container(
            color: Colors.blue,
            child: SizedOverflowBox(
              alignment: Alignment.topCenter,
              size: Size(100, 50),
              child: Container(
                width: 50,
                height: 80,
                color: Colors.amber,
              ),
            ),
          ),

5.OverflowBox与SizedOverflowBox的区别

不了解OverflowBox可以看一下:Flutter(56):Layout组件之OverflowBox

          Container(
            color: Colors.blue,
            child: SizedOverflowBox(
              alignment: Alignment.topCenter,
              size: Size(100, 50),
              child: Container(
                width: 50,
                height: 80,
                color: Colors.amber,
              ),
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: 50),
            color: Colors.blue,
            constraints: BoxConstraints(
              maxHeight: 50,
            ),
            child: SizedOverflowBox(
              alignment: Alignment.topCenter,
              size: Size(100, 50),
              child: Container(
                width: 50,
                height: 80,
                color: Colors.amber,
              ),
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: 50),
            color: Colors.blue,
            height: 50,
            constraints: BoxConstraints(
              maxHeight: 50,
            ),
            child: OverflowBox(
              alignment: Alignment.topCenter,
              minWidth: 20,
              maxWidth: 100,
              maxHeight: 100,
              minHeight: 20,
              child: Container(
                width: 50,
                height: 120,
                color: Colors.amber,
              ),
            ),
          )
image.png

下一节:Layout组件之SizedBox

Flutter(57):Layout组件之SizedBox

Flutter教学目录持续更新中

Github源代码持续更新中

上一篇 下一篇

猜你喜欢

热点阅读