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({
    'addAutomaticKeepAlives':
        true == addAutomaticKeepAlives ? null : addAutomaticKeepAlives,
    'addRepaintBoundaries':
        true == addRepaintBoundaries ? null : addRepaintBoundaries,
    'addSemanticIndexes':
        true == addSemanticIndexes ? null : addSemanticIndexes,
    'cacheExtent': cacheExtent,
    'clipBehavior': Clip.hardEdge == clipBehavior
        ? null
        : ThemeEncoder.encodeClip(
            clipBehavior,
          ),
    'controller': controller,
    'dragStartBehavior': DragStartBehavior.start == dragStartBehavior
        ? null
        : ThemeEncoder.encodeDragStartBehavior(
            dragStartBehavior,
          ),
    'findChildIndexCallback': findChildIndexCallback,
    'itemExtent': itemExtent,
    'keyboardDismissBehavior':
        ScrollViewKeyboardDismissBehavior.manual == keyboardDismissBehavior
            ? null
            : ThemeEncoder.encodeScrollViewKeyboardDismissBehavior(
                keyboardDismissBehavior,
              ),
    'padding': ThemeEncoder.encodeEdgeInsets(
      padding,
    ),
    'physics': ThemeEncoder.encodeScrollPhysics(
      physics,
    ),
    'primary': primary,
    'prototypeItem': prototypeItem?.toJson(),
    'restorationId': restorationId,
    'reverse': false == reverse ? null : reverse,
    'scrollDirection': Axis.vertical == scrollDirection
        ? null
        : ThemeEncoder.encodeAxis(
            scrollDirection,
          ),
    'shrinkWrap': false == shrinkWrap ? null : shrinkWrap,
    'children': JsonClass.maybeToJsonList(children),
    ...args,
  });
}