fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"autofocus": "<bool>",
"clipBehavior": "<Clip>",
"focusNode": "<FocusNode>",
"onFocusChange": "<ValueChanged<bool>",
"onHover": "<ValueChanged<bool>>",
"onLongPress": "<VoidCallback>",
"onPressed": "<VoidCallback>",
"statesController": "<MaterialStatesController>",
"style": "<ButtonStyle>"
}
As a note, the FocusNode, ValueChanged, and VoidCallback 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.decodeButtonStyle
ThemeDecoder.decodeClip
Implementation
static JsonElevatedButtonBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonElevatedButtonBuilder? result;
if (map != null) {
result = JsonElevatedButtonBuilder(
autofocus: map['autofocus'] == null
? false
: JsonClass.parseBool(
map['autofocus'],
),
clipBehavior: ThemeDecoder.decodeClip(
map['clipBehavior'],
validate: false,
) ??
Clip.none,
focusNode: map['focusNode'],
onFocusChange: map['onFocusChange'],
onHover: map['onHover'],
onLongPress: map['onLongPress'],
onPressed: map['onPressed'],
statesController: map['statesController'],
style: ThemeDecoder.decodeButtonStyle(
map['style'],
validate: false,
),
);
}
return result;
}