getDecoration method
Implementation
Decoration? getDecoration() {
BorderRadiusGeometry? borderRadiusGeometry;
if (radius != null) {
//所有的角度
borderRadiusGeometry = BorderRadius.all(Radius.circular(radius!));
} else {
//否则就是,各个角度
borderRadiusGeometry = BorderRadius.only(
topLeft: Radius.circular(leftTopRadius != null ? leftTopRadius! : 0),
topRight:
Radius.circular(rightTopRadius != null ? rightTopRadius! : 0),
bottomLeft:
Radius.circular(leftBottomRadius != null ? leftBottomRadius! : 0),
bottomRight: Radius.circular(
rightBottomRadius != null ? rightBottomRadius! : 0));
}
Gradient? tGradient;
if (gradient != null) {
tGradient = LinearGradient(
colors: gradientColorList != null ? gradientColorList! : [],
// 设置有哪些渐变色
begin: gradientBegin != null ? gradientBegin! : Alignment.centerLeft,
// 渐变色开始的位置,默认 centerLeft
end: gradientEnd != null ? gradientEnd! : Alignment.centerRight,
// 渐变色结束的位置,默认 centerRight
stops: gradientColorStops, // 颜色值梯度,取值范围[0,1],长度要和 colors 的长度一样
);
}
Decoration? widgetDecoration = BoxDecoration(
gradient: tGradient,
//背景颜色
color: solidColor != null ? solidColor! : Colors.transparent,
//圆角半径
borderRadius: isCircle == true ? null : borderRadiusGeometry,
//是否是圆形
shape: isCircle == true ? BoxShape.circle : BoxShape.rectangle,
//边框线宽、颜色
border: Border.all(
width: strokeWidth != null ? strokeWidth! : 0,
color: strokeColor != null ? strokeColor! : Colors.transparent),
);
return widgetDecoration;
}