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