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({
    'duration': duration.inMilliseconds,
    'layoutBuilder': AnimatedSwitcher.defaultLayoutBuilder == layoutBuilder
        ? null
        : layoutBuilder,
    'reverseDuration': reverseDuration?.inMilliseconds,
    'switchInCurve': Curves.linear == switchInCurve
        ? null
        : CurvesValues.encode(switchInCurve),
    'switchOutCurve': Curves.linear == switchOutCurve
        ? null
        : CurvesValues.encode(switchOutCurve),
    'transitionBuilder':
        AnimatedSwitcher.defaultTransitionBuilder == transitionBuilder
            ? null
            : transitionBuilder,
    'child': child?.toJson(),
    ...args,
  });
}