expects<T> method
Reads a value of type T
from the backing map by key
, expecting it to be exactly of type T
.
Implementation
T expects<T>(String key, [String? message]) {
final value = _backing[key];
if (value is T) return value;
throw DogSerializerException(
message: message ?? "Expected type $T for field '$key' but got ${value.runtimeType}");
}