addWithField<P extends Object, F extends Object, TField extends FormField<F>> method

void addWithField<P extends Object, F extends Object, TField extends FormField<F>>({
  1. required String name,
  2. List<FormFieldValidatorFactory<F>>? validatorFactories,
  3. List<AsyncValidatorFactory<F>>? asyncValidatorFactories,
  4. P? initialValue,
  5. Equality<F>? fieldValueEquality,
  6. Equality<P>? propertyValueEquality,
  7. ValueConverter<P, F>? valueConverter,
  8. PropertyValueTraits? valueTraits,
  9. 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,
    );