toJson method

  1. @override
Map<String, dynamic> toJson()
override

Abstract function that concrete classes must implement. This must encode the internal data model to a JSON compatible representation.

While not required, it is suggested to call removeNull before returning.

Implementation

@override
Map<String, dynamic> toJson() {
  return JsonClass.removeNull({
    'locale': ThemeEncoder.encodeLocale(
      locale,
    ),
    'maxLines': maxLines,
    'overflow': TextOverflow.clip == overflow
        ? null
        : ThemeEncoder.encodeTextOverflow(
            overflow,
          ),
    'selectionColor': ThemeEncoder.encodeColor(
      selectionColor,
    ),
    'selectionRegistrar': selectionRegistrar,
    'softWrap': true == softWrap ? null : softWrap,
    'strutStyle': ThemeEncoder.encodeStrutStyle(
      strutStyle,
    ),
    'text': text,
    'textAlign': TextAlign.start == textAlign
        ? null
        : ThemeEncoder.encodeTextAlign(
            textAlign,
          ),
    'textDirection': ThemeEncoder.encodeTextDirection(
      textDirection,
    ),
    'textHeightBehavior': ThemeEncoder.encodeTextHeightBehavior(
      textHeightBehavior,
    ),
    'textScaleFactor': 1.0 == textScaleFactor ? null : textScaleFactor,
    'textScaler': TextScaler.noScaling == textScaler ? null : textScaler,
    'textWidthBasis': TextWidthBasis.parent == textWidthBasis
        ? null
        : ThemeEncoder.encodeTextWidthBasis(
            textWidthBasis,
          ),
    ...args,
  });
}