fromDynamic static method

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

{
  "debugLabel": "<String>",
  "initialScrollOffset": "<double>",
  "keepScrollOffset": "<bool>",
  "key": "<String>"
}

Where the value of the key attribute is the key used on the JsonWidgetRegistry.setValue to store the current ScrollController.

Implementation

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

  if (map != null) {
    result = JsonSetScrollControllerBuilder(
      debugLabel: map['debugLabel'],
      initialScrollOffset:
          JsonClass.maybeParseDouble(map['initialScrollOffset']),
      keepScrollOffset: JsonClass.parseBool(
        map['keepScrollOffset'],
        whenNull: true,
      ),
      key: map['key'] ?? 'scrollController',
    );
  }

  return result;
}