fromDynamic static method
Builds the builder from a Map-like dynamic structure. The scaffold is a
special case that uses child
as an alias for the body
attribute. This
preserves the tree-like structure of the dynamic widgets internally but
allows developers to use the more common terms. This expects the JSON
format to be of the following structure:
{
"appBar": "<JsonWidgetData>",
"backgroundColor": "<Color>",
"body": "<JsonWidgetData>",
"bottomNavigationBar": "<JsonWidgetData>",
"bottomSheet": "<JsonWidgetData>",
"drawer": "<JsonWidgetData>",
"drawerDragStartBehavior": "<DragStartBehavior>",
"drawerEdgeDragWidth": "<double>",
"drawerEnableOpenDragGesture": "<bool>",
"drawerScrimColor": "<Color>",
"endDrawer": "<JsonWidgetData>",
"endDrawerEnableOpenDragGesture": "<bool>",
"extendBody": "<bool>",
"extendBodyBehindAppBar": "<bool>",
"floatingActionButton": "<JsonWidgetData>",
"floatingActionButtonAnimator": "<FloatingActionButtonAnimator>",
"floatingActionButtonLocation": "<ActionButtonLocation>",
"onDrawerChanged": "<ValueChanged<bool>>",
"onEndDrawerChanged": "<ValueChanged<bool>>",
"persistentFooterAlignment": "<AlignmentDirectional>",
"persistentFooterButtons": "<List<JsonWidgetData>>",
"primary": "<bool>",
"resizeToAvoidBottomInset": "<bool>",
"restorationId": "<String>"
}
See also:
- JsonWidgetData.fromDynamic
ThemeDecoder.decodeDragStartBehavior
ThemeDecoder.decodeFloatingActionButtonAnimator
ThemeDecoder.decodeFloatingActionButtonLocation
Implementation
static JsonScaffoldBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonScaffoldBuilder? result;
if (map != null) {
result = JsonScaffoldBuilder(
appBar: JsonWidgetData.fromDynamic(
map['appBar'],
registry: registry,
),
backgroundColor: ThemeDecoder.decodeColor(
map['backgroundColor'],
validate: false,
),
body: JsonWidgetData.fromDynamic(
map['body'],
registry: registry,
),
bottomNavigationBar: JsonWidgetData.fromDynamic(
map['bottomNavigationBar'],
registry: registry,
),
bottomSheet: JsonWidgetData.fromDynamic(
map['bottomSheet'],
registry: registry,
),
drawer: JsonWidgetData.fromDynamic(
map['drawer'],
registry: registry,
),
drawerDragStartBehavior: ThemeDecoder.decodeDragStartBehavior(
map['drawerDragStartBehavior'],
validate: false,
) ??
DragStartBehavior.start,
drawerEdgeDragWidth:
JsonClass.maybeParseDouble(map['drawerEdgeDragWidth']),
drawerEnableOpenDragGesture: map['drawerEnableOpenDragGesture'] == null
? true
: JsonClass.parseBool(map['drawerEnableOpenDragGesture']),
drawerScrimColor: ThemeDecoder.decodeColor(
map['drawerScrimColor'],
validate: false,
),
endDrawer: JsonWidgetData.fromDynamic(
map['endDrawer'],
registry: registry,
),
endDrawerEnableOpenDragGesture:
map['endDrawerEnableOpenDragGesture'] == null
? true
: JsonClass.parseBool(map['endDrawerEnableOpenDragGesture']),
extendBody: JsonClass.parseBool(map['extendBody']),
extendBodyBehindAppBar:
JsonClass.parseBool(map['extendBodyBehindAppBar']),
floatingActionButton: JsonWidgetData.fromDynamic(
map['floatingActionButton'],
registry: registry,
),
floatingActionButtonAnimator:
ThemeDecoder.decodeFloatingActionButtonAnimator(
map['floatingActionButtonAnimator'],
validate: false,
),
floatingActionButtonLocation:
ThemeDecoder.decodeFloatingActionButtonLocation(
map['floatingActionButtonLocation'],
validate: false,
),
onDrawerChanged: map['onDrawerChanged'],
onEndDrawerChanged: map['onEndDrawerChanged'],
persistentFooterAlignment: ThemeDecoder.decodeAlignmentDirectional(
map['persistentFooterAlignment'],
validate: false,
) ??
AlignmentDirectional.centerEnd,
persistentFooterButtons: JsonClass.maybeFromDynamicList(
map['persistentFooterButtons'],
(map) => JsonWidgetData.fromDynamic(
map['persistentFooterButtons'],
registry: registry,
)!,
),
primary:
map['primary'] == null ? true : JsonClass.parseBool(map['primary']),
resizeToAvoidBottomInset: map['resizeToAvoidBottomInset'] == null
? null
: JsonClass.parseBool(map['resizeToAvoidBottomInset']),
restorationId: map['restorationId'],
);
}
return result;
}