valueTransformer property
Called just before field value is saved. Used to massage data just before committing the value.
This sample shows how to convert age in a FormBuilderTextField
to number
so that the final value is numeric instead of a String
FormBuilderTextField(
name: 'age',
decoration: InputDecoration(labelText: 'Age'),
valueTransformer: (text) => num.tryParse(text),
validator: FormBuilderValidators.numeric(context),
initialValue: '18',
keyboardType: TextInputType.number,
),
Implementation
final ValueTransformer<T?>? valueTransformer;