encodeDialogTextStyle function

Map<String, Object?>? encodeDialogTextStyle(
  1. BuildContext context, {
  2. String? fontFamily,
  3. CNDialogTextStyle? title,
  4. CNDialogTextStyle? message,
  5. CNDialogTextStyle? action,
})

The textStyle of a dialog's show payload, or null for the system look.

Implementation

Map<String, Object?>? encodeDialogTextStyle(
  BuildContext context, {
  String? fontFamily,
  CNDialogTextStyle? title,
  CNDialogTextStyle? message,
  CNDialogTextStyle? action,
}) {
  Map<String, Object?>? part(CNDialogTextStyle? style) {
    if (style == null) return null;
    final map = <String, Object?>{
      'fontFamily': ?style.fontFamily,
      'fontSize': ?style.fontSize,
      'fontWeight': ?style.fontWeight?.value,
      'color': ?resolveColorToArgb(style.color, context),
    };
    return map.isEmpty ? null : map;
  }

  final encoded = <String, Object?>{
    'fontFamily': ?fontFamily,
    'title': ?part(title),
    'message': ?part(message),
    'action': ?part(action),
  };
  return encoded.isEmpty ? null : encoded;
}