encodeTextStyle static method
Encodes a given value
into a JSON compatible Map structure. This will
return the following structure:
"backgroundColor": <Color>,
"color": <Color>,
"decoration": <TextDecoration>,
"decorationColor": <Color>,
"decorationStyle": <TextDecorationStyle>,
"decorationThickness": <double>,
"fontFamily": value['fontFamily'],
"fontFamilyFallback": <String[]>,
"fontFeatures": <FontFeature[]>,
"fontWeight": <FontWeight>,
"fontSize": <double>,
"fontStyle": <FontStyle>,
"height": <double>,
"inherit": <bool>,
"letterSpacing": <double>,
"locale": <Locale>,
"package": <String>,
"shadows": <Shadow[]>,
"textBaseline": <TextBaseline>,
"wordSpacing": <double>
See also:
Implementation
static Map<String, dynamic>? encodeTextStyle(TextStyle? value) {
Map<String, dynamic>? result;
if (value != null) {
result = <String, dynamic>{
'backgroundColor': encodeColor(value.backgroundColor),
'color': encodeColor(value.color),
'decoration': encodeTextDecoration(value.decoration),
'decorationColor': encodeColor(value.decorationColor),
'decorationStyle': encodeTextDecorationStyle(value.decorationStyle),
'decorationThickness': value.decorationThickness,
'fontFamily': value.fontFamily,
'fontFamilyFallback': value.fontFamilyFallback,
'fontFeatures': value.fontFeatures == null
? null
: value.fontFeatures!
.map(
(value) => encodeFontFeature(value),
)
.toList(),
'fontWeight': encodeFontWeight(value.fontWeight),
'fontSize': value.fontSize,
'fontStyle': encodeFontStyle(value.fontStyle),
'height': value.height,
'inherit': value.inherit,
'letterSpacing': value.letterSpacing,
'locale': encodeLocale(value.locale),
'shadows': value.shadows == null
? null
: value.shadows!
.map(
(value) => encodeShadow(value),
)
.toList(),
'textBaseline': encodeTextBaseline(value.textBaseline),
'wordSpacing': value.wordSpacing,
};
}
return _stripNull(result);
}