fromDynamic static method

JsonTweenAnimationBuilder? fromDynamic(
  1. dynamic map, {
  2. JsonWidgetRegistry? registry,
})

Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:

{
  "builder": "<ValueWidgetBuilder>",
  "curve": "<Curve>",
  "duration": "<int; millis>",
  "onEnd": "<VoidCallback>",
  "tween": "<Tween>"
}

As a note, the ValueWidgetBuilder, Curve, VoidCallback cannot be decoded via JSON. Instead, the only way to bind those values to the builder is to use a function or a variable reference via the JsonWidgetRegistry. The Tween can only be bound through a function reference.

Implementation

static JsonTweenAnimationBuilder? fromDynamic(
  dynamic map, {
  JsonWidgetRegistry? registry,
}) {
  JsonTweenAnimationBuilder? result;

  if (map != null) {
    result = JsonTweenAnimationBuilder(
      builder: map['builder'],
      curve: map['curve'] ?? Curves.linear,
      duration: JsonClass.maybeParseDurationFromMillis(
        map['duration'],
      )!,
      onEnd: map['onEnd'],
      tween: map['tween'],
    );
  }

  return result;
}