fromDynamic static method

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

{
  "alignment": <AlignmentGeometry>,
  "clipBehavior": <Clip>,
  "curve": <Curve>,
  "duration": <int; millis>,
  "reverseDuration": <int; millis>,
  "vsync": <TickerProvider>,
}

As a note, the Curve and TickerProvider 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. But if vsync is not passed, the widget itself will be the TickerProvider.

Implementation

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

  if (map != null) {
    result = JsonAnimatedSizeBuilder(
      alignment: ThemeDecoder.decodeAlignment(
            map['alignment'],
            validate: false,
          ) ??
          Alignment.center,
      clipBehavior: ThemeDecoder.decodeClip(map['clipBehavior']),
      curve: map['curve'] ?? Curves.linear,
      duration: JsonClass.parseDurationFromMillis(
        map['duration'],
      )!,
      reverseDuration: JsonClass.parseDurationFromMillis(
        map['reverseDuration'],
      ),
      vsync: map['vsync'],
    );
  }

  return result;
}