stringConvertibleWithField<P extends Object, TField extends FormField<String>> method

void stringConvertibleWithField<P extends Object, TField extends FormField<String>>({
  1. required String name,
  2. List<FormFieldValidatorFactory<String>>? validatorFactories,
  3. List<AsyncValidatorFactory<String>>? asyncValidatorFactories,
  4. P? initialValue,
  5. required StringConverter<P>? stringConverter,
  6. PropertyValueTraits? valueTraits,
})

Defines a new property with property value type P and preferred form field type TField for form field value type String.

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 stringConvertibleWithField<P extends Object,
        TField extends FormField<String>>({
  required String name,
  List<FormFieldValidatorFactory<String>>? validatorFactories,
  List<AsyncValidatorFactory<String>>? asyncValidatorFactories,
  P? initialValue,
  required StringConverter<P>? stringConverter,
  PropertyValueTraits? valueTraits,
}) =>
    addWithField<P, String, TField>(
      name: name,
      validatorFactories: validatorFactories,
      asyncValidatorFactories: asyncValidatorFactories,
      initialValue: initialValue,
      valueConverter: stringConverter,
      valueTraits: valueTraits,
      restorableValueFactory: stringRestorableValueFactory,
    );