fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"alignment": <Alignment>,
"autofocus": <bool>,
"color": <Color>,
"constraints": <BoxConstraints>,
"disabledColor": <Color>,
"enableFeedback": <bool>,
"focusColor": <Color>,
"focusNode": <FocusNode>,
"highlightColor": <Color>,
"hoverColor": <Color>,
"icon": <JsonWidgetData>,
"iconSize": <double>,
"mouseCursor": <MouseCursor>,
"onPressed": <VoidCallback>,
"padding": <EdgeInsetsGeometry>,
"splashColor": <Color>,
"splashRadius": <double>,
"tooltip": <String>,
"visualDensity": <VisualDensity>,
}
This can accept a "child" in place of the "icon". This considers both of those as synonyms and if both are set, the "icon" will take preference.
As a note, the FocusNode, 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.decodeAlignment
ThemeDecoder.decodeBoxConstraints
ThemeDecoder.decodeColor
ThemeDecoder.decodeEdgeInsetsGeometry
ThemeDecoder.decodeMouseCursor
ThemeDecoder.decodeVisualDensity
Implementation
static JsonIconButtonBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonIconButtonBuilder? result;
if (map != null) {
result = JsonIconButtonBuilder(
alignment:
ThemeDecoder.decodeAlignment(map['alignment']) ?? Alignment.center,
autofocus: JsonClass.parseBool(map['autofocus']),
color: ThemeDecoder.decodeColor(map['color']),
constraints: ThemeDecoder.decodeBoxConstraints(map['constraints']),
disabledColor: ThemeDecoder.decodeColor(map['disabledColor']),
enableFeedback: map['enableFeedback'] == null
? true
: JsonClass.parseBool(map['enableFeedback']),
focusColor: ThemeDecoder.decodeColor(map['focusColor']),
focusNode: map['focusColor'],
highlightColor: ThemeDecoder.decodeColor(map['highlightColor']),
hoverColor: ThemeDecoder.decodeColor(map['hoverColor']),
icon: JsonWidgetData.fromDynamic(map['icon']),
iconSize: JsonClass.parseDouble(map['iconSize'], 24.0)!,
mouseCursor: ThemeDecoder.decodeMouseCursor(map['mouseCursor']) ??
SystemMouseCursors.click,
onPressed: map['onPressed'],
padding: ThemeDecoder.decodeEdgeInsetsGeometry(map['padding']) ??
const EdgeInsets.all(8.0),
splashColor: ThemeDecoder.decodeColor(map['splashColor']),
splashRadius: JsonClass.parseDouble(map['splashRadius']),
tooltip: map['tooltip']?.toString(),
visualDensity: ThemeDecoder.decodeVisualDensity(map['visualDensity']),
);
}
return result;
}