decoration property
CSSBoxDecoration?
get
decoration
What decoration to paint, should get value after layout.
Implementation
CSSBoxDecoration? get decoration {
List<Radius>? radius = this.borderRadius;
List<BorderSide>? borderSides = this.borderSides;
if (backgroundColor == null &&
backgroundImage == null &&
borderSides == null &&
radius == null &&
shadows == null) {
return null;
}
Border? border;
if (borderSides != null) {
// Side read inorder left top right bottom.
border = Border(left: borderSides[0], top: borderSides[1], right: borderSides[2], bottom: borderSides[3]);
}
BorderRadius? borderRadius;
// Flutter border radius only works when border is uniform.
if (radius != null && (border == null || border.isUniform)) {
borderRadius = BorderRadius.only(
topLeft: radius[0],
topRight: radius[1],
bottomRight: radius[2],
bottomLeft: radius[3],
);
}
Gradient? gradient = backgroundImage?.gradient;
if (gradient is BorderGradientMixin && border != null) {
gradient.borderEdge = border.dimensions as EdgeInsets;
}
DecorationImage? decorationImage;
ImageProvider? image = backgroundImage?.image;
if (image!= null) {
decorationImage = DecorationImage(
image: image,
repeat: backgroundRepeat,
);
}
return CSSBoxDecoration(
boxShadow: shadows,
color: gradient != null ? null : backgroundColor, // FIXME: chrome will work with gradient and color.
image: decorationImage,
border: border,
borderRadius: borderRadius,
gradient: gradient,
);
}