EasyCustomFormField<T, C extends ValueNotifier> constructor
EasyCustomFormField<T, C extends ValueNotifier> ({
- Key? key,
- required String name,
- C? controller,
- FocusNode? focusNode,
- T? initialValue,
- required CreateControllerCallback<
C, T?> controllerBuilder, - RecreateControllerCallback<
C> ? controllerRebuilder, - ValueOfGetter<
T?, C> ? valueGet, - ValueOfSetter<
T?, C> ? valueSet, - required EasyFormCustomFieldBuilder<
T, C> builder, - ValueChanged<
T> ? onChanged, - FormFieldSetter<
T> ? onSaved, - EasyFormFieldValidator<
T?> ? validator, - bool enabled = true,
- EasyAutovalidateMode autovalidateMode = EasyAutovalidateMode.disabled,
Creates a EasyCustomFormField that contains a custom field.
When a controller
is specified, initialValue
must be null (the
default). If controller
is null, then a Controller
will be constructed automatically and its value will be initialized
to initialValue
or the empty value.
Implementation
EasyCustomFormField({
Key? key,
required String name,
this.controller,
FocusNode? focusNode,
T? initialValue,
required this.controllerBuilder,
this.controllerRebuilder,
this.valueGet,
this.valueSet,
required EasyFormCustomFieldBuilder<T, C> builder,
ValueChanged<T>? onChanged,
FormFieldSetter<T>? onSaved,
EasyFormFieldValidator<T?>? validator,
bool enabled = true,
EasyAutovalidateMode autovalidateMode = EasyAutovalidateMode.disabled,
}) : super(
key: key,
name: name,
focusNode: focusNode,
initialValue: controller != null
? ((valueGet != null)
? valueGet.call(controller)
: controller.value)
: (initialValue ?? null),
onSaved: onSaved,
validator: validator,
enabled: enabled,
autovalidateMode: autovalidateMode,
builder: (EasyFormFieldState<T?> field) {
final _EasyCustomFormFieldState<T, C> state =
field as _EasyCustomFormFieldState<T, C>;
void onChangedHandler(T value) {
if (onChanged != null) {
onChanged(value);
}
field.didChange(value);
}
return builder(state, onChangedHandler);
},
);