//容器组件的使用 外面的column的高度是固定的
new Container(
  alignment: Alignment.center,
    padding: const EdgeInsets.all(8.0),
    margin:const EdgeInsets.all(8.0),
    constraints: new BoxConstraints.expand(
      height: Theme.of(context).textTheme.display1.fontSize*1.1+200,
    ),
    width: 300.0,
    height: 200.0,

    decoration: buildBoxDecoration(),
    foregroundDecoration: BoxDecoration(),
    child: new Text('容器演示'),
    transform: new Matrix4.rotationZ(0.1),
),
//下面是BoxDecoration的封装,
Decoration buildBoxDecoration()
{
  //dart 1.0 需要new dart2.0不需要new
  return new BoxDecoration(
    color:const Color(0xfffce5cd),
    border: new Border.all(
      color: const Color(0xfffce5cd),
      width: 8.0,
    ),
  );
}
Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐