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({
    'animationDuration':
        kThemeChangeDuration == animationDuration
            ? null
            : animationDuration.inMilliseconds,
    'borderOnForeground':
        true == borderOnForeground ? null : borderOnForeground,
    'borderRadius': ThemeEncoder.encodeBorderRadius(borderRadius),
    'clipBehavior':
        Clip.none == clipBehavior
            ? null
            : ThemeEncoder.encodeClip(clipBehavior),
    'color': ThemeEncoder.encodeColor(color),
    'elevation': 0.0 == elevation ? null : elevation,
    'margin': ThemeEncoder.encodeEdgeInsetsGeometry(margin),
    'materialType':
        MaterialType.canvas == materialType
            ? null
            : ThemeEncoder.encodeMaterialType(materialType),
    'padding': ThemeEncoder.encodeEdgeInsetsGeometry(padding),
    'shadowColor': ThemeEncoder.encodeColor(shadowColor),
    'shape': ThemeEncoder.encodeShapeBorder(shape),
    'surfaceTintColor': ThemeEncoder.encodeColor(surfaceTintColor),
    'textStyle': ThemeEncoder.encodeTextStyle(textStyle),
    'child': child?.toJson(),

    ...args,
  });
}