build method
Widget
build({
- required BuildContext context,
- required FormMapper mapper,
- required TypeProperty property,
- required Keywords args,
override
build and bind the corresponding widget
context
a FormMapper
mapper
the FormMapper
property
a TypeProperty
args
and parameters that will be handled by the adapter
Implementation
@override
Widget build({required BuildContext context, required FormMapper mapper, required TypeProperty property, required Keywords args}) {
WidgetProperty? widgetProperty = mapper.findWidget(property.path);
DisplayValue<dynamic,dynamic> displayValue;
ParseValue<dynamic, dynamic> parseValue;
FormFieldValidator<String> validate;
TextInputType textInputType;
List<TextInputFormatter> inputFormatters;
(displayValue, parseValue, validate, textInputType, inputFormatters) = customize(property);
TextEditingController? controller;
FocusNode? focusNode;
if ( widgetProperty != null) {
controller = widgetProperty.args["controller"];
focusNode = widgetProperty.args["focusNode"];
}
else {
controller = TextEditingController();
focusNode = FocusNode();
controller.addListener(() {
mapper.notifyChange(property: property, value: parseValue(controller!.text));
});
} // else
TextFormField result = TextFormField(
key: ValueKey(property.path),
controller: controller,
focusNode: focusNode,
style: args.get<TextStyle>('style'),
validator: validate,
keyboardType: textInputType,
inputFormatters: inputFormatters
);
mapper.map(property: property, widget: result, adapter: this, displayValue: displayValue, parseValue: parseValue);
if ( widgetProperty == null) {
widgetProperty = mapper.findWidget(property.path)!;
widgetProperty.args["controller"] = controller;
widgetProperty.args["focusNode"] = focusNode;
}
return result;
}