toMap method
Implementation
Map<String, dynamic> toMap() {
final map = <String, dynamic>{
if (title != null) 'title': title,
if (icon != null) 'icon': icon,
'dismissOnTap': dismissOnTap,
};
// Add styling properties if provided
if (backgroundColor != null) map['backgroundColor'] = backgroundColor!.value;
if (textColor != null) map['textColor'] = textColor!.value;
if (iconColor != null) map['iconColor'] = iconColor!.value;
if (height != null) map['height'] = height;
if (fontSize != null) map['fontSize'] = fontSize;
if (iconSize != null) map['iconSize'] = iconSize;
if (iconLabelSpacing != null) map['iconLabelSpacing'] = iconLabelSpacing;
if (fontWeight != null) {
// Map FontWeight to Swift weight value
final weightMap = {
FontWeight.w100: 100,
FontWeight.w200: 200,
FontWeight.w300: 300,
FontWeight.w400: 400,
FontWeight.w500: 500,
FontWeight.w600: 600,
FontWeight.w700: 700,
FontWeight.w800: 800,
FontWeight.w900: 900,
};
map['fontWeight'] = weightMap[fontWeight] ?? 400;
}
return map;
}