fromDynamic static method

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

{
  "addAutomaticKeepAlives": <bool>,
  "addRepaintBoundaries": <bool>,
  "addSemanticIndexes": <bool>,
  "cacheExtent": <double>,
  "clipBehavior": <Clip>,
  "controller": <ScrollController>,
  "dragStartBehavior": <DragStartBehavior>,
  "itemExtent": <double>,
  "keyboardDismissBehavior": <ScrollViewKeyboardDismissBehavior>,
  "padding": <EdgeInsetsGeometry>,
  "physics": <ScrollPhysics>,
  "primary": <bool>,
  "prototypeItem": <JsonWidgetData>,
  "restorationId": <String>,
  "reverse": <bool>,
  "scrollDirection": <Axis>,
  "shrinkWrap": <bool>
}

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

See also:

  • ThemeDecoder.decodeAxis
  • ThemeDecoder.decodeClip
  • ThemeDecoder.decodeDragStartBehavior
  • ThemeDecoder.decodeEdgeInsetsGeometry
  • ThemeDecoder.decodeScrollPhysics

Implementation

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

  if (map != null) {
    result = JsonListViewBuilder(
      addAutomaticKeepAlives: map['addAutomaticKeepAlives'] == null
          ? true
          : JsonClass.parseBool(map['addAutomaticKeepAlives']),
      addRepaintBoundaries: map['addRepaintBoundaries'] == null
          ? true
          : JsonClass.parseBool(map['addRepaintBoundaries']),
      addSemanticIndexes: map['addSemanticIndexes'] == null
          ? true
          : JsonClass.parseBool(map['addSemanticIndexes']),
      cacheExtent: JsonClass.parseDouble(map['cacheExtent']),
      clipBehavior: ThemeDecoder.decodeClip(
            map['clipBehavior'],
            validate: false,
          ) ??
          Clip.hardEdge,
      controller: map['controller'],
      dragStartBehavior: ThemeDecoder.decodeDragStartBehavior(
            map['dragStartBehavior'],
            validate: false,
          ) ??
          DragStartBehavior.start,
      itemExtent: JsonClass.parseDouble(map['itemExtent']),
      keyboardDismissBehavior:
          ThemeDecoder.decodeScrollViewKeyboardDismissBehavior(
                map['keyboardDismissBehavior'],
                validate: false,
              ) ??
              ScrollViewKeyboardDismissBehavior.manual,
      padding: ThemeDecoder.decodeEdgeInsetsGeometry(
        map['padding'],
        validate: false,
      ) as EdgeInsets?,
      physics: ThemeDecoder.decodeScrollPhysics(
        map['physics'],
        validate: false,
      ),
      primary: JsonClass.parseBool(map['primary']),
      restorationId: map['restorationId'],
      reverse: JsonClass.parseBool(map['reverse']),
      scrollDirection: ThemeDecoder.decodeAxis(
            map['scrollDirection'],
            validate: false,
          ) ??
          Axis.vertical,
      shrinkWrap: JsonClass.parseBool(map['shrinkWrap']),
    );
  }

  return result;
}