get<T> method

T get<T>(
  1. String key
)

Reads a value. Throws if the database value is null. Throws if the key is missing from the schema or the type mismatches.

Implementation

T get<T>(String key) {
  _validateAccess<T>(key);

  final value = _raw[key];
  if (value == null) {
    throw StateError(
        'Null Error: Column "$key" is null in DB, but get<$T> was called.');
  }
  if (value is! T) {
    throw StateError(
      'DB Type Mismatch: Expected $T for "$key", got ${value.runtimeType}.',
    );
  }
  return value;
}