encodeTextSpan static method

Map<String, dynamic>? encodeTextSpan(
  1. TextSpan? value
)

Encodes a TextStyle object into a JSON map:

{
  "children": "<List<TextSpan>>",
  "locale": "<Locale>",
  "mouseCursor": "<MouseCursor>",
  "onEnter": "<PointerEnterEventListener>",
  "onExit": "<PointerExitEventListener>",
  "recognizer": "<GestureRecognizer>",
  "semanticsLabel": "<String>",
  "spellOut": "<bool>",
  "style": "<TextStyle>",
  "text": "<String>"
}

See Also:

Implementation

static Map<String, dynamic>? encodeTextSpan(TextSpan? value) {
  Map<String, dynamic>? result;

  if (value != null) {
    result = {
      'children': value.children
          ?.whereType<TextSpan>()
          .map((e) => encodeTextSpan(e)!)
          .toList(),
      'locale': encodeLocale(value.locale),
      'mouseCursor': encodeMouseCursor(value.mouseCursor),
      // 'onEnter': @unencodable,
      // 'onExit': @unencodable,
      // 'recognizer': @unencodable,
      'semanticsLabel': value.semanticsLabel,
      'spellOut': value.spellOut,
      'style': encodeTextStyle(value.style),
      'text': value.text,
    };
  }

  return _stripDynamicNull(result);
}