operator [] method

dynamic operator [](
  1. String name
)

Gets the value of a field by name.

Parameters:

  • name: The name of the field.

Returns:

  • The value of the field.

Throws:

  • Exception if the field does not exist.

Implementation

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