operator []= method

void operator []=(
  1. String name,
  2. dynamic value
)

Sets the value of a field by name.

Parameters:

  • name: The name of the field.
  • value: The new value to set.

Throws:

  • Exception if the field does not exist.

Implementation

operator []=(String name, value) {
  for (final field in fields) {
    if (field.fieldName == name) {
      field.value = value;
      return;
    }
  }
  throw Exception("Field $name does not exist");
}