setFieldValue<T> method

void setFieldValue<T>(
  1. String id,
  2. T? value, {
  3. bool notifyField = true,
})

Sets the value for a form field with the specified id

The value parameter is the new value to set for the field. If notifyField is true (the default), this will call the didChange method of the field state to update its value and all the side effects, like validation and notifying listeners.

If you don't want to trigger those side effects, but only want to change the form's map value set notifyField to false.

Implementation

void setFieldValue<T>(String id, T? value, {bool notifyField = true}) {
  _value[id] = value;
  if (notifyField) {
    // ignore: avoid_dynamic_calls
    _fields[id]?.didChange(_fromValueTransformers[id]?.call(value) ?? value);
  }
}