MContainer constructor
MContainer({
- Key? key,
- double? size,
- double? width,
- double? height,
- BoxConstraints? constraints,
- AlignmentGeometry? alignment,
- BoxBorder? border,
- BorderRadius? borderRadius,
- Widget? child,
- Clip clipBehavior = Clip.none,
- Color? color,
- Decoration? decoration,
- BoxFit? fit,
- Decoration? foregroundDecoration,
- Gradient? gradient,
- String? image,
- AlignmentGeometry? imageAlignment,
- ImageProvider<
Object> ? imageProvider, - EdgeInsetsGeometry? margin,
- EdgeInsetsGeometry? padding,
- double? radius,
- ImageRepeat repeat = ImageRepeat.noRepeat,
- double scale = 1.0,
- List<
BoxShadow> ? shadows, - BorderSide? side,
- Matrix4? transform,
- AlignmentGeometry? transformAlignment,
- Rect? centerSlice,
- double? maxHeight,
- double? maxWidth,
- double? minHeight,
- double? minWidth,
- MBoxShape? shape,
- AssetBundle? bundle,
- String? package,
- Map<
String, String> ? headers,
创建一个 Container 组件, 可以设置宽高,边框,圆角等属性
width 宽度
height 高度
size 尺寸
child 子组件
alignment 对齐方式
border 边框
borderRadius 圆角
clipBehavior 裁剪
color 背景色
decoration 装饰
fit 图片填充模式
foregroundDecoration 前景装饰
gradient 渐变
image 图片
imageAlignment 图片对齐方式
imageProvider 图片提供者
margin 外边距
padding 内边距
radius 圆角
repeat 图片重复模式
scale 图片缩放
shadows 阴影
side 边框
transform 旋转
transformAlignment 旋转对齐方式
centerSlice 图片切片
maxHeight 最大高度
maxWidth 最大宽度
minHeight 最小高度
minWidth 最小宽度
shape 形状
constraints 约束
Implementation
MContainer({
super.key,
double? size,
double? width,
double? height,
BoxConstraints? constraints,
this.alignment,
this.border,
this.borderRadius,
this.child,
this.clipBehavior = Clip.none,
this.color,
this.decoration,
this.fit,
this.foregroundDecoration,
this.gradient,
this.image,
this.imageAlignment,
this.imageProvider,
this.margin,
this.padding,
this.radius,
this.repeat = ImageRepeat.noRepeat,
this.scale = 1.0,
this.shadows,
this.side,
this.transform,
this.transformAlignment,
this.centerSlice,
this.maxHeight,
this.maxWidth,
this.minHeight,
this.minWidth,
this.shape,
this.bundle,
this.package,
this.headers,
}) : assert(margin == null || margin.isNonNegative),
assert(padding == null || padding.isNonNegative),
assert(decoration == null || decoration.debugAssertIsValid()),
assert(constraints == null || constraints.debugAssertIsValid()),
assert(decoration != null || clipBehavior == Clip.none),
constraints = (width != null || height != null || size != null)
? constraints?.tighten(width: width ?? size, height: height ?? size) ??
BoxConstraints.tightFor(width: width ?? size, height: height ?? size)
: constraints;