|
|
|
|
|
|
BoxConstraints constraints = null, |
|
|
|
EdgeInsets margin = null, |
|
|
|
Matrix4 transfrom = null, |
|
|
|
Widget child = null |
|
|
|
) : base(key) { |
|
|
|
Widget child = null, |
|
|
|
Clip clipBehavior = Clip.none |
|
|
|
) : base(key: key) { |
|
|
|
D.assert(margin == null || margin.isNonNegative); |
|
|
|
D.assert(padding == null || padding.isNonNegative); |
|
|
|
D.assert(decoration == null || decoration.debugAssertIsValid()); |
|
|
|
|
|
|
"The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\"." |
|
|
|
); |
|
|
|
|
|
|
|
D.assert(clipBehavior != null); |
|
|
|
|
|
|
|
this.alignment = alignment; |
|
|
|
this.padding = padding; |
|
|
|
foregroundDecoration = forgroundDecoration; |
|
|
|
|
|
|
|
|
|
|
this.color = color; |
|
|
|
|
|
|
|
this.clipBehavior = clipBehavior; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly Widget child; |
|
|
|
|
|
|
public readonly BoxConstraints constraints; |
|
|
|
public readonly EdgeInsets margin; |
|
|
|
public readonly Matrix4 transform; |
|
|
|
public readonly Color color; |
|
|
|
public readonly Clip clipBehavior; |
|
|
|
|
|
|
|
EdgeInsets _paddingIncludingDecoration { |
|
|
|
get { |
|
|
|
|
|
|
current = new Padding(padding: effetivePadding, child: current); |
|
|
|
} |
|
|
|
|
|
|
|
if (color != null) |
|
|
|
current = new ColoredBox(color: color, child: current); |
|
|
|
|
|
|
|
if (decoration != null) { |
|
|
|
current = new DecoratedBox(decoration: decoration, child: current); |
|
|
|
} |
|
|
|
|
|
|
current = new Transform(transform: new Matrix4(transform), child: current); |
|
|
|
} |
|
|
|
|
|
|
|
if (clipBehavior != Clip.none) { |
|
|
|
current = new ClipPath( |
|
|
|
clipper: new _DecorationClipper( |
|
|
|
textDirection: Directionality.of(context), |
|
|
|
decoration: decoration |
|
|
|
), |
|
|
|
clipBehavior: clipBehavior, |
|
|
|
child: current |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
return current; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
alignment, showName: false, defaultValue: foundation_.kNullDefaultValue)); |
|
|
|
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", |
|
|
|
padding, defaultValue: foundation_.kNullDefaultValue)); |
|
|
|
properties.add(new DiagnosticsProperty<Decoration>("bg", |
|
|
|
properties.add(new DiagnosticsProperty<Clip>("clipBehavior", clipBehavior, defaultValue: Clip.none)); |
|
|
|
if (color != null) |
|
|
|
properties.add(new DiagnosticsProperty<Color>("bg", color)); |
|
|
|
else |
|
|
|
properties.add(new DiagnosticsProperty<Decoration>("bg", |
|
|
|
decoration, defaultValue: foundation_.kNullDefaultValue)); |
|
|
|
properties.add(new DiagnosticsProperty<Decoration>("fg", |
|
|
|
foregroundDecoration, defaultValue: foundation_.kNullDefaultValue)); |
|
|
|
|
|
|
margin, defaultValue: foundation_.kNullDefaultValue)); |
|
|
|
properties.add(ObjectFlagProperty<Matrix4>.has("transform", |
|
|
|
transform)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// A clipper that uses [Decoration.getClipPath] to clip.
|
|
|
|
public class _DecorationClipper : CustomClipper<Path> { |
|
|
|
public _DecorationClipper( |
|
|
|
TextDirection textDirection = TextDirection.rtl, |
|
|
|
Decoration decoration = null |
|
|
|
) { |
|
|
|
D.assert(decoration != null); |
|
|
|
textDirection = TextDirection.ltr; |
|
|
|
} |
|
|
|
|
|
|
|
public readonly TextDirection textDirection; |
|
|
|
public readonly Decoration decoration; |
|
|
|
|
|
|
|
public override Path getClip(Size size) { |
|
|
|
return decoration.getClipPath(Offset.zero & size, textDirection); |
|
|
|
} |
|
|
|
|
|
|
|
public override bool shouldReclip(CustomClipper<Path> oldClipper) { |
|
|
|
return ((_DecorationClipper)oldClipper).decoration != decoration |
|
|
|
|| ((_DecorationClipper)oldClipper).textDirection != textDirection; |
|
|
|
} |
|
|
|
} |
|
|
|
} |