getBoxDecoration method
Implementation
BoxDecoration? getBoxDecoration(String? backgroundId, String? borderId,
List<int>? cornerRadius, String? borderThickness) {
final backgroundColor = getColor(backgroundId);
final borderColor = getColor(borderId);
final double thickness = double.tryParse(borderThickness ?? '0') ?? 0;
if (backgroundColor == null &&
borderColor == null &&
thickness == 0 &&
(cornerRadius == null || cornerRadius.isEmpty)) {
return null;
}
BorderRadius? borderRadius;
if (cornerRadius != null && cornerRadius.length == 4) {
borderRadius = BorderRadius.only(
topLeft: Radius.circular(cornerRadius[0].toDouble()),
topRight: Radius.circular(cornerRadius[1].toDouble()),
bottomRight: Radius.circular(cornerRadius[2].toDouble()),
bottomLeft: Radius.circular(cornerRadius[3].toDouble()),
);
}
return BoxDecoration(
color: backgroundColor,
borderRadius: borderRadius,
border: borderColor != null && thickness > 0
? Border.all(color: borderColor, width: thickness)
: null,
);
}