fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"activeColor": <Color>,
"autovalidateMode": <AutovalidateMode>,
"autofocus": <bool>,
"checkColor": <Color>,
"enabled": <bool>,
"fillColor": <MaterialStateProperty<Color>>,
"focusColor": <Color>,
"focusNode": <FocusNode>,
"groupValue": <dynamic>,
"hoverColor": <Color>,
"id": <String>,
"label": <String>,
"materialTapTargetSize": <MaterialTapTargetSize>,
"mouseCursor": <MouseCursor>,
"onChanged": <ValueCallback<dynamic>>,
"onSaved": <ValueCallback<dynamic>>,
"overlayColor": <MaterialStateProperty<Color>>,
"toggleable": <bool>,
"splashRadius": <double>,
"validators": <ValueValidators[]>,
"value": <dynamic>,
"visualDensity": <VisualDensity>,
}
As a note, the FocusNode and ValueCallback<bool>
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:
- buildCustom
ThemeDecoder.decodeAutovalidateMode
ThemeDecoder.decodeColor
ThemeDecoder.decodeMaterialTapTargetSize
ThemeDecoder.decodeVisualDensity
Validator
Implementation
static JsonRadioBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonRadioBuilder? result;
if (map != null) {
result = JsonRadioBuilder(
activeColor: ThemeDecoder.decodeColor(
map['activeColor'],
validate: false,
),
autofocus: JsonClass.parseBool(map['autofocus']),
autovalidateMode: map['autovalidate'] == null
? ThemeDecoder.decodeAutovalidateMode(map['autovalidateMode'])
: JsonClass.parseBool(map['autovalidate']) == true
? AutovalidateMode.always
: AutovalidateMode.disabled,
enabled:
map['enabled'] == null ? true : JsonClass.parseBool(map['enabled']),
fillColor: ThemeDecoder.decodeMaterialStatePropertyColor(
map['fillColor'],
),
focusColor: ThemeDecoder.decodeColor(
map['focusColor'],
validate: false,
),
focusNode: map['focusNode'],
groupValue: map['groupValue'],
hoverColor: ThemeDecoder.decodeColor(
map['hoverColor'],
validate: false,
),
id: map['id'],
materialTapTargetSize: ThemeDecoder.decodeMaterialTapTargetSize(
map['materialTapTargetSize'],
validate: false,
),
mouseCursor: ThemeDecoder.decodeMouseCursor(
map['mouseCursor'],
validate: false,
),
onChanged: map['onChanged'],
onSaved: map['onSaved'],
overlayColor: ThemeDecoder.decodeMaterialStatePropertyColor(
map['overlayColor'],
),
splashRadius: JsonClass.parseDouble(map['splashRadius']),
toggleable: JsonClass.parseBool(map['toggleable']),
validator: map['validators'] == null
? null
: Validator.fromDynamic({'validators': map['validators']}),
value: map['value'],
visualDensity: ThemeDecoder.decodeVisualDensity(
map['visualDensity'],
validate: false,
),
);
}
return result;
}