fromDynamic static method

JsonSliverToBoxAdapterBuilder? 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>",
  "findChildIndexCallback": "<ChildIndexGetter>",
  "semanticIndexCallback": "<SemanticIndexCallback>",
  "semanticIndexOffset": "<int>"
}

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.

Implementation

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

  if (map != null) {
    result = JsonSliverToBoxAdapterBuilder(
      addAutomaticKeepAlives: JsonClass.parseBool(
        map['addAutomaticKeepAlives'],
        whenNull: true,
      ),
      addRepaintBoundaries: JsonClass.parseBool(
        map['addRepaintBoundaries'],
        whenNull: true,
      ),
      addSemanticIndexes: JsonClass.parseBool(
        map['addSemanticIndexes'],
        whenNull: true,
      ),
      findChildIndexCallback: map['findChildIndexCallback'],
      semanticIndexCallback: map['semanticIndexCallback'],
      semanticIndexOffset:
          JsonClass.maybeParseInt(map['semanticIndexOffset']) ?? 0,
    );
  }

  return result;
}