fromDynamic static method

JsonAnimatedThemeBuilder? 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:

{
  "curve": <Curve>,
  "data": <ThemeData>,
  "duration": <int; millis>,
  "onEnd": <VoidCallback>,
}

As a note, the Curve and 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.

Implementation

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

  if (map != null) {
    result = JsonAnimatedThemeBuilder(
      curve: map['curve'] ?? Curves.linear,
      data: ThemeDecoder.decodeThemeData(
        map['data'],
        validate: false,
      )!,
      duration: JsonClass.parseDurationFromMillis(
            map['duration'],
          ) ??
          kThemeAnimationDuration,
      onEnd: map['onEnd'],
    );
  }

  return result;
}