toJson method
Implementation
Map<String, Object> toJson() {
_validateColor('primaryColor', primaryColor);
_validateColor('backgroundColor', backgroundColor);
_validateColor('textColor', textColor);
final radius = cornerRadius;
if (radius != null && (!radius.isFinite || radius < 0 || radius > 40)) {
throw ArgumentError.value(
radius,
'cornerRadius',
'must be between 0 and 40',
);
}
return {
if (primaryColor case final value?) 'primaryColor': value,
if (backgroundColor case final value?) 'backgroundColor': value,
if (textColor case final value?) 'textColor': value,
if (radius != null) 'cornerRadius': radius,
};
}