registerAs<T> method

void registerAs<T>()

Method store Type provided by generic parameter T in types

The Type can be added to types only if _instance conforms to T. If _instance is not conform to T then StateError throws

Implementation

void registerAs<T>() {
  if (_instance is T) {
    _types.add(T);
  } else {
    throw StateError('Type ${_instance.runtimeType} is not conform to $T');
  }
}