fromDynamic static method
Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:
{
"autocorrect": "<bool>",
"autofillHints": "<List<String>>",
"autofocus": "<bool>",
"autovalidateMode": "<AutovalidateMode>",
"buildCounter": "<InputCounterWidgetBuilder>",
"contextMenuBuilder": "<EditableTextContextMenuBuilder>",
"controller": "<TextEditingController>",
"cursorColor": "<Color>",
"cursorHeight": "<double>",
"cursorRadius": "<Radius>",
"cursorWidth": "<double>",
"decoration": "<InputDecorationDecoder>",
"enableIMEPersonalizedLearning": "<bool>",
"enableInteractiveSelection": "<bool>",
"enableSuggestions": "<bool>",
"enabled": "<bool>",
"expands": "<bool>",
"focusNode": "<FocusNode>",
"initialValue": "<String>",
"inputFormatters": "<List<TextInputFormatter>>",
"keyboardAppearance": "<Brightness>",
"keyboardType": "<TextInputType>",
"maxLength": "<int>",
"maxLengthEnforced": "<bool>",
"maxLines": "<int>",
"minLines": "<int>",
"mouseCursor": "<MouseCursor>",
"obscureText": "<bool>",
"obscuringCharacter": "<String>",
"onChanged": "<ValueChanged<String>>",
"onEditingComplete": "<VoidCallback>",
"onFieldSubmitted": "<ValueChanged<String>>",
"onSaved": "<FormFieldSetter<String>>",
"onTap": "<VoidCallback>",
"onTapOutside": "<TapRegionCallback>",
"readOnly": "<bool>",
"restorationId": "<bool>",
"scrollController": "<ScrollController>",
"scrollPadding": "<EdgeInsetsGeometry>",
"scrollPhysics": "<ScrollPhysics>",
"selectionControls": "<TextSelectionControls>",
"showCursor": "<bool>",
"smartDashesType": "<SmartDashesType>",
"smartQuotesType": "<SmartQuotesType>",
"strutStyle": "<StrutStyle>",
"style": "<TextStyle>",
"textAlign": "<TextAlign>",
"textAlignVertical": "<TextAlignVertical>",
"textCapitalization": "<TextCapitalization>",
"textDirection": "<TextDirection>",
"textInputAction": "<TextInputAction>",
"validators": "<List<ValueValidator>>"
}
See also:
- buildCustom
- InputDecorationDecoder.fromDynamic
ThemeDecoder.decodeAutovalidateMode
ThemeDecoder.decodeBrightness
ThemeDecoder.decodeColor
ThemeDecoder.decodeEdgeInsetsGeometry
ThemeDecoder.decodeMaxLengthEnforcement
ThemeDecoder.decodeMouseCursor
ThemeDecoder.decodeRadius
ThemeDecoder.decodeScrollPhysics
ThemeDecoder.decodeSmartDashesType
ThemeDecoder.decodeSmartQuotesType
ThemeDecoder.decodeTextAlign
ThemeDecoder.decodeTextAlignVertical
ThemeDecoder.decodeTextCapitalization
ThemeDecoder.decodeTextInputAction
ThemeDecoder.decodeTextInputType
ThemeDecoder.decodeTextStyle
Validator
Implementation
static JsonTextFormFieldBuilder? fromDynamic(
dynamic map, {
JsonWidgetRegistry? registry,
}) {
JsonTextFormFieldBuilder? result;
if (map != null) {
result = JsonTextFormFieldBuilder(
autocorrect: map['autocorrect'] == null
? true
: JsonClass.parseBool(map['autocorrect']),
autofillHints: map['autofillHints'] == null
? null
: List<String>.from(map['autofillHints']),
autofocus: JsonClass.parseBool(map['autofocus']),
autovalidateMode: map['autovalidate'] == null
? ThemeDecoder.decodeAutovalidateMode(
map['autovalidateMode'],
validate: false,
)
: JsonClass.parseBool(map['autovalidate']) == true
? AutovalidateMode.always
: AutovalidateMode.disabled,
buildCounter: map['buildCounter'],
contextMenuBuilder: map['contextMenuBuilder'],
controller: map['controller'] ??
TextEditingController(text: map['initialValue']),
cursorColor: ThemeDecoder.decodeColor(
map['cursorColor'],
validate: false,
),
cursorHeight: JsonClass.maybeParseDouble(map['cursorHeight']),
cursorRadius: ThemeDecoder.decodeRadius(
map['cursorRadius'],
validate: false,
),
cursorWidth: JsonClass.maybeParseDouble(map['cursorWidth'], 2)!,
decoration: map['decoration'],
enableIMEPersonalizedLearning:
map['enableIMEPersonalizedLearning'] == null
? true
: JsonClass.parseBool(map['enableIMEPersonalizedLearning']),
enableInteractiveSelection: map['enableInteractiveSelection'] == null
? true
: JsonClass.parseBool(map['enableInteractiveSelection']),
enableSuggestions: map['enableSuggestions'] == null
? true
: JsonClass.parseBool(map['enableSuggestions']),
enabled:
map['enabled'] == null ? true : JsonClass.parseBool(map['enabled']),
expands: JsonClass.parseBool(map['expands']),
focusNode: map['focusNode'],
inputFormatters: map['inputFormatters'],
keyboardAppearance: ThemeDecoder.decodeBrightness(
map['keyboardBrightness'],
validate: false,
),
keyboardType: ThemeDecoder.decodeTextInputType(
map['keyboardType'],
validate: false,
),
maxLength: JsonClass.maybeParseInt(map['maxLength']),
maxLengthEnforcement: ThemeDecoder.decodeMaxLengthEnforcement(
map['maxLengthEnforcement'],
validate: false,
),
maxLines: map.containsKey('maxLines')
? JsonClass.maybeParseInt(map['maxLines'])
: 1,
minLines: JsonClass.maybeParseInt(map['minLines']),
mouseCursor: ThemeDecoder.decodeMouseCursor(
map['mouseCursor'],
validate: false,
),
obscureText: JsonClass.parseBool(map['obscureText']),
obscuringCharacter: map['obscuringCharacter'] ?? '•',
onChanged: map['onChanged'],
onEditingComplete: map['onEditingComplete'],
onFieldSubmitted: map['onFieldSubmitted'],
onSaved: map['onSaved'],
onTap: map['onTap'],
onTapOutside: map['onTapOutside'],
readOnly: JsonClass.parseBool(map['readOnly']),
restorationId: map['restorationId'],
scrollPadding: ThemeDecoder.decodeEdgeInsetsGeometry(
map['scrollPadding'],
validate: false,
) ??
const EdgeInsets.all(20.0),
scrollPhysics: ThemeDecoder.decodeScrollPhysics(
map['scrollPhysics'],
validate: false,
),
selectionControls: map['selectionControls'],
showCursor: map['showCursor'] == null
? null
: JsonClass.parseBool(map['showCursor']),
smartDashesType: ThemeDecoder.decodeSmartDashesType(
map['smartDashesType'],
validate: false,
),
smartQuotesType: ThemeDecoder.decodeSmartQuotesType(
map['smartQuotesType'],
validate: false,
),
strutStyle: ThemeDecoder.decodeStrutStyle(
map['strutStyle'],
validate: false,
),
style: ThemeDecoder.decodeTextStyle(
map['style'],
validate: false,
),
textAlign: ThemeDecoder.decodeTextAlign(
map['textAlign'],
validate: false,
) ??
TextAlign.start,
textAlignVertical: ThemeDecoder.decodeTextAlignVertical(
map['textAlignVertical'],
validate: false,
),
textCapitalization: ThemeDecoder.decodeTextCapitalization(
map['textCapitalization'],
validate: false,
) ??
TextCapitalization.none,
textDirection: ThemeDecoder.decodeTextDirection(
map['textDirection'],
validate: false,
),
textInputAction: ThemeDecoder.decodeTextInputAction(
map['textInputAction'],
validate: false,
),
validator: map['validators'] == null
? null
: Validator.fromDynamic({
'validators': map['validators'],
}),
);
}
return result;
}