textStyle static method

Map<String, dynamic>? textStyle(
  1. TextStyle? style
)

Returns a TextStyle from the specified map.

If the map is absent, returns null.

Otherwise (even if it has no keys), the TextStyle is created from the following keys: color (color), backgroundColor (color), fontSize (double), fontWeight (enumValue of FontWeight), fontStyle (enumValue of FontStyle), letterSpacing (double), wordSpacing (double), textBaseline (enumValue of TextBaseline), height (double), leadingDistribution (enumValue of TextLeadingDistribution), locale (locale), foreground (paint), background (paint), shadows (list of boxShadows), fontFeatures (list of fontFeatures), decoration (textDecoration), decorationColor (color), decorationStyle (enumValue of TextDecorationStyle), decorationThickness (double), 'fontFamily(string),fontFamilyFallback([list] of [string]), andoverflow` (enumValue of TextOverflow).

Implementation

static Map<String, dynamic>? textStyle(TextStyle? style) {
  if (style == null) return null;
  return NotNullMap.from({
    'color': color(style.color),
    'backgroundColor': color(style.backgroundColor),
    'fontSize': style.fontSize,
    'fontWeight': enumValue(style.fontWeight),
    'fontStyle': enumValue(style.fontStyle),
    'letterSpacing': style.letterSpacing,
    'wordSpacing': style.wordSpacing,
    'textBaseline': enumValue(style.textBaseline),
    'height': style.height,
    'leadingDistribution': enumValue(style.leadingDistribution),
    'locale': locale(style.locale),
    'foreground': paint(style.foreground),
    'background': paint(style.background),
    'shadows': list<Shadow, Map<String, dynamic>?>(style.shadows, boxShadow),
    'fontFeatures': list<FontFeature, Map<String, dynamic>?>(
        style.fontFeatures, fontFeature),
    'decoration': textDecoration(style.decoration),
    'decorationColor': color(style.decorationColor),
    'decorationStyle': enumValue(style.decorationStyle),
    'decorationThickness': style.decorationThickness,
    'fontFamily': style.fontFamily,
    'fontFamilyFallback':
        list<String, String?>(style.fontFamilyFallback, string),
  });
}