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({
    'clipBehavior': Clip.none == clipBehavior
        ? null
        : ThemeEncoder.encodeClip(
            clipBehavior,
          ),
    'color': ThemeEncoder.encodeColor(
      color,
    ),
    'constraints': ThemeEncoder.encodeBoxConstraints(
      constraints,
    ),
    'elevation': elevation,
    'enableFeedback': enableFeedback,
    'enabled': true == enabled ? null : enabled,
    'icon': icon?.toJson(),
    'iconColor': ThemeEncoder.encodeColor(
      iconColor,
    ),
    'iconSize': iconSize,
    'initialValue': initialValue,
    'itemBuilder': itemBuilder,
    'offset': Offset.zero == offset
        ? null
        : ThemeEncoder.encodeOffset(
            offset,
          ),
    'onCanceled': onCanceled,
    'onOpened': onOpened,
    'onSelected': onSelected,
    'padding': const EdgeInsets.all(8.0) == padding
        ? null
        : ThemeEncoder.encodeEdgeInsetsGeometry(
            padding,
          ),
    'popUpAnimationStyle': popUpAnimationStyle,
    'position': ThemeEncoder.encodePopupMenuPosition(
      position,
    ),
    'routeSettings': routeSettings,
    'shadowColor': ThemeEncoder.encodeColor(
      shadowColor,
    ),
    'shape': ThemeEncoder.encodeShapeBorder(
      shape,
    ),
    'splashRadius': splashRadius,
    'style': ThemeEncoder.encodeButtonStyle(
      style,
    ),
    'surfaceTintColor': ThemeEncoder.encodeColor(
      surfaceTintColor,
    ),
    'tooltip': tooltip,
    'useRootNavigator': false == useRootNavigator ? null : useRootNavigator,
    'child': child?.toJson(),
    ...args,
  });
}