textStyleToJson static method
Implementation
static Map<String, dynamic>? textStyleToJson(TextStyle? e) {
if (e == null) return null;
final entries = {
"backgroundColor": colorToHex(e.backgroundColor),
"color": colorToHex(e.color),
"decorationThickness": e.decorationThickness,
"decorationStyle": enumToJson(e.decorationStyle),
"decorationColor": colorToHex(e.decorationColor),
"decoration": e.decoration?.toString(),
"debugLabel": e.debugLabel,
"fontSize": e.fontSize,
"fontWeight": e.fontWeight?.value,
"fontFamily": e.fontFamily,
"fontStyle": enumToJson(e.fontStyle),
"fontFamilyFallback": e.fontFamilyFallback,
"fontFeatures": e.fontFeatures?.map((e) => e.value).toList(),
"fontVariations": e.fontVariations
?.map((e) => {"value": e.value, "axis": e.axis})
.toList(),
"height": e.height,
"letterSpacing": e.letterSpacing,
"leadingDistribution": enumToJson(e.leadingDistribution),
"locale": e.locale?.toString(),
"overflow": enumToJson(e.overflow),
"shadows": e.shadows
?.map((e) => {
"color": colorToHex(e.color),
"offset": offsetToJson(e.offset),
"blurRadius": e.blurRadius,
})
.toList(),
"textBaseline": enumToJson(e.textBaseline),
"wordSpacing": e.wordSpacing,
}.entries.where((e) => e.value != null);
if (entries.isEmpty) return null;
return Map.fromEntries(entries);
}