您的当前位置:首页Flutter之Container组件

Flutter之Container组件

2024-12-11 来源:哗拓教育

/**
    Container({
    Key key,//唯一标识符,用于查找更新
    this.alignment,//控制child的对齐方式
    this.padding,//内边距
    Color color,//背景色
    Decoration decoration,//绘制在child下层的装饰,不能与color同时使用
    this.foregroundDecoration,//绘制在child上层的装饰
    double width,//
    double height,//
    BoxConstraints constraints,//添加到child上额外的约束条件
    this.margin,//
    this.transform,//设置container的变换矩阵,类型为Matrix4。
    this.child,//
    })
 */
/**
    const BoxDecoration({
    this.color,
    this.image,
    this.border,
    this.borderRadius,
    this.boxShadow,//border四周添加阴影效果
    this.gradient,//装饰器的过度效果,比如可以用来给组件添加一个蒙层
    this.backgroundBlendMode,
    this.shape = BoxShape.rectangle,
    })
 */
body: Container(
          width: 350.0,
          height: 350.0,
          padding: EdgeInsets.all(50.0),
          color: Color(0xfff1f1f1),
          child: Center(
            child: Container(
              width: 300.0,
              height: 300.0,
              decoration: BoxDecoration(
                  color: Color(0xffffffff),
                  border: Border.all(color: Color(0xffff0000), width: 1.0),
                  borderRadius: BorderRadius.circular(10.0),
                  shape: BoxShape.rectangle,
                  image: DecorationImage(image: NetworkImage(
                      
                  boxShadow: [
                    BoxShadow(color: Color(0xffff0000), blurRadius: 6),
                  ]
              ),
//              transform: Matrix4.rotationZ(0.5),
              child: Center(
                child: Container(
                  width: 100.0,
                  height: 100.0,
                  alignment: Alignment.center,
                  foregroundDecoration: BoxDecoration(
                      color: Color(0xffff0000),
                      border: Border.all(color: Color(0xff000000), width: 5.0),
                      gradient: LinearGradient(
                          colors: [
                            Color(0x880000ff),
                            Color(0x8800ff00),
                            Color(0x88ff0000),
                          ])
                  ),
                  child: Text("这是个widget"),
                ),
              ),
            ),
          ),
        ),
显示全文