encode method

  1. @override
Map<String, dynamic> encode(
  1. TextStyle? obj

Convert obj of type T to a map of String to json encodable objects. Can only be called once for each object in data heap.


Map<String, dynamic> encode(TextStyle? obj) {
  const l = LocaleCodec();
  const c = ColorCodec();
  if (obj == null) return {};
  return {
    'inherit': obj.inherit,
    'color': c.encode(obj.color),
    'backgroundColor': c.encode(obj.backgroundColor),
    'fontSize': obj.fontSize,
    'fontWeight': obj.fontWeight?.index,
    'fontStyle': obj.fontStyle?.index,
    'letterSpacing': obj.letterSpacing,
    'wordSpacing': obj.wordSpacing,
    'textBaseline': obj.textBaseline?.index,
    'height': obj.height,
    'leading': obj.leadingDistribution?.index,
    'locale': l.encode(obj.locale),
    'decorationColor': c.encode(obj.decorationColor),
    'decorationStyle': obj.decorationStyle?.index,
    'decorationThickness': obj.decorationThickness,
    'fontFamily': obj.fontFamily,
    'fontFamilyFallback': obj.fontFamilyFallback,
    'overflow': obj.overflow?.index,