Field.builder constructor
Field.builder(
- String key, {
- required NyFieldBuilder builder,
- String? label,
- dynamic value,
- FormValidator? validator,
- bool autofocus = false,
- String? dummyData,
- Widget? header,
- TextStyle? titleStyle,
- bool? readOnly,
- FieldStyle? style,
- dynamic onChanged(
- dynamic value
Field.builder is a constructor that lets developers create custom form fields inline using a builder function.
The builder receives the BuildContext, an onChanged callback to
report value changes to the form, and the currentValue of the field.
Example:
Field.builder(
'favorite_color',
builder: (context, onChanged, value) {
return ColorPicker(
selected: value,
onColorChanged: (color) => onChanged(color),
);
},
value: Colors.blue,
validator: FormValidator().notEmpty(),
)
Implementation
Field.builder(
this.key, {
required NyFieldBuilder builder,
this.label,
dynamic value,
this.validator,
this.autofocus = false,
this.dummyData,
this.header,
this.footer,
this.titleStyle,
this.hidden = false,
this.readOnly,
FieldStyle? style,
Function(dynamic value)? onChanged,
}) : _value = value,
this.style = style {
setOnChanged(onChanged);
widget = NyFormBuilder.fromField(this, builder: builder);
}