Flutter基础组件-Container

2020-01-03  本文已影响0人  橘子有毒

效果图

效果图

Container属性列表

Container示例代码

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MyContainer extends StatefulWidget{
  @override
  State<StatefulWidget> createState() => _MyContainerState();
}

class _MyContainerState extends State<MyContainer> {
  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,//child的对齐方式 Alignment.topLeft,topCenter,topRight,centerLeft,center,centerRight,bottomLeft,bottomCenter,bottomRight
      padding: EdgeInsets.all(3.0),//内部间隔区域,可响应点击
      margin: EdgeInsets.all(50),//外部间隔区域,不响应点击
//      color: Color(0xffffffff), //设置颜色,不能和 decoration一起用
      decoration: new BoxDecoration(//设置装饰器,可设置边框、主体、阴影等
        color:  Color(0xffffffff),
        border:Border.all(color:Color(0xffd9d9d9)),
        borderRadius: BorderRadius.circular(10.0),
        boxShadow:[
          BoxShadow(
              color: Color(0xfff4f4f4),
              offset: Offset(10,10)
          ),
        ],
      ),
      foregroundDecoration: new BoxDecoration(//设置前景装饰器,可设置边框、主体、阴影等
        color: Color(0x00000000),
      ),
      width: 300,//view宽
      height: 100,////view高
      constraints:BoxConstraints(minHeight: 80,minWidth: 80),//约束布局,控制子view的大小
      transform: Matrix4.rotationZ(0.1),//设置矩阵变换
      child: Text('这是一个 Container'),//包含的子view
    );
  }

}
上一篇 下一篇

猜你喜欢

热点阅读