addWithField<P extends Object, F extends Object, TField extends FormField<F> > method
void
addWithField<P extends Object, F extends Object, TField extends FormField<F> >({
- required String name,
- List<
FormFieldValidatorFactory< ? validatorFactories,F> > - List<
AsyncValidatorFactory< ? asyncValidatorFactories,F> > - P? initialValue,
- Equality<
F> ? fieldValueEquality, - Equality<
P> ? propertyValueEquality, - ValueConverter<
P, F> ? valueConverter, - PropertyValueTraits? valueTraits,
- RestorableValueFactory<
F> ? restorableValueFactory,
Defines a new property with property value type P
,
form field value type F
, and preferred form field type TField
.
Note that name
must be unique, and validators are registered as
factories instead of normal closures (function objects) because some
validation framework requires live BuildContext to initialize validator,
and current Locale of the application should be stored to
BuildContext.
TField
affects FormFieldFactory
generation by form_companion_generator
.
Implementation
void addWithField<P extends Object, F extends Object,
TField extends FormField<F>>({
required String name,
List<FormFieldValidatorFactory<F>>? validatorFactories,
List<AsyncValidatorFactory<F>>? asyncValidatorFactories,
P? initialValue,
Equality<F>? fieldValueEquality,
Equality<P>? propertyValueEquality,
ValueConverter<P, F>? valueConverter,
PropertyValueTraits? valueTraits,
RestorableValueFactory<F>? restorableValueFactory,
}) =>
// NOTE: TField is not used in runtime.
// The parameter will be interpreted in form_companion_generator.
add<P, F>(
name: name,
validatorFactories: validatorFactories,
asyncValidatorFactories: asyncValidatorFactories,
initialValue: initialValue,
fieldValueEquality: fieldValueEquality,
propertyValueEquality: propertyValueEquality,
valueConverter: valueConverter,
valueTraits: valueTraits,
restorableValueFactory: restorableValueFactory,
);