flutter

Flutter Container(容器)

2018-12-06  本文已影响23人  iwakevin

Container是一个容器组件,在大多数时候,是使用它做一些变形、边距、之类的包裹层。

new Container(
    width: 200.0,
    height: 200.0,
    margin: const EdgeInsets.all(20.0),
    decoration: new BoxDecoration(
        color: Colors.blue[400],
        borderRadius: new BorderRadius.all(
            const Radius.circular(100.0),
        ),
        boxShadow: <BoxShadow>[
            new BoxShadow(
                spreadRadius: 1.0,
                blurRadius: 5.0,
                offset: const Offset(0.6, 1.2),
                color: Colors.black26,
            )
        ]
    ),
),

Container 有以下常用属性:

ConstrainedBox

ConstrainedBox 是一个带约束的容器,只有 width,height 的大小约束。

new ConstrainedBox(
    constraints: new BoxConstraints(
        maxHeight: 100.0,
        maxWidth: 100.0,
        minHeight: 50.0,
        minWidth: 50.0
    ),
    child: new Image.network(this.imgsrc),
)
上一篇 下一篇

猜你喜欢

热点阅读