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({
    'alignment':
        AlignmentDirectional.topStart == alignment
            ? null
            : ThemeEncoder.encodeAlignmentGeometry(alignment),
    'clipBehavior':
        Clip.hardEdge == clipBehavior
            ? null
            : ThemeEncoder.encodeClip(clipBehavior),
    'fit': StackFit.loose == fit ? null : ThemeEncoder.encodeStackFit(fit),
    'textDirection': ThemeEncoder.encodeTextDirection(textDirection),
    'children':
        const <JsonWidgetData>[] == children
            ? null
            : JsonClass.toJsonList(children),

    ...args,
  });
}