getControl<T extends BloomFormControl> method

T getControl<T extends BloomFormControl>(
  1. String name
)

Returns the registered control under name typed as T.

Throws StateError if no control with name exists or if it is not of type T.

Implementation

T getControl<T extends BloomFormControl>(String name) {
  final field = _fields[name];
  if (field == null) {
    throw StateError('BloomForm: No field registered with name "$name".');
  }
  if (field is! T) {
    throw StateError(
        'BloomForm: Field "$name" is of type ${field.runtimeType}, expected $T.');
  }
  return field;
}