fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"anchor": <double>,
"cacheExtent": <double>,
"clipBehavior": <Clip>,
"center": <Key>,
"controller": <ScrollController>,
"dragStartBehavior": <DragStartBehavior>,
"keyboardDismissBehavior": <ScrollViewKeyboardDismissBehavior>,
"padding": <EdgeInsetsGeometry>,
"physics": <ScrollPhysics>,
"primary": <bool>,
"restorationId": <String>,
"reverse": <bool>,
"scrollBehavior": <ScrollBehavior>,
"scrollDirection": <Axis>,
"semanticChildCount": <int>,
"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.decodeDragStartBehavior
ThemeDecoder.decodeEdgeInsetsGeometry
ThemeDecoder.decodeScrollBehavior
ThemeDecoder.decodeScrollPhysics
ThemeDecoder.decodeScrollViewKeyboardDismissBehavior
Implementation
static JsonCustomScrollViewBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonCustomScrollViewBuilder? result;
if (map != null) {
result = JsonCustomScrollViewBuilder(
anchor: JsonClass.parseDouble(map['anchor']),
cacheExtent: JsonClass.parseDouble(map['cacheExtent']),
center:
map['center'] is String ? ValueKey(map['center']) : map['center'],
clipBehavior:
ThemeDecoder.decodeClip(map['clipBehavior']) ?? Clip.hardEdge,
controller: map['controller'],
dragStartBehavior: ThemeDecoder.decodeDragStartBehavior(
map['dragStartBehavior'],
validate: false,
) ??
DragStartBehavior.start,
keyboardDismissBehavior:
ThemeDecoder.decodeScrollViewKeyboardDismissBehavior(
map['keyboardDismissBehavior'],
validate: false,
),
physics: ThemeDecoder.decodeScrollPhysics(
map['physics'],
validate: false,
),
primary:
map['primary'] == null ? null : JsonClass.parseBool(map['primary']),
restorationId: map['restorationId'],
reverse: JsonClass.parseBool(map['reverse']),
scrollBehavior: ThemeDecoder.decodeScrollBehavior(
map['scrollBehavior'],
validate: false,
),
scrollDirection: ThemeDecoder.decodeAxis(
map['scrollDirection'],
validate: false,
) ??
Axis.vertical,
semanticChildCount: JsonClass.parseInt(map['semanticChildCount']),
shrinkWrap: JsonClass.parseBool(map['shrinkWrap']),
);
}
return result;
}