getMeta<T> method
Returns the metadata entry for the given key or type argument.
If no metadata entry is found, throws an exception or automatically
calls the orElse function to initialize the metadata entry and return it.
Implementation
T getMeta<T>({Object? key, T Function()? orElse}) {
key ??= T;
final data = _metadata[key] as T;
if (data == null) {
if (orElse != null) {
final newValue = orElse();
_metadata[key] = newValue;
return newValue;
}
throw DogException("No data for key $key");
}
return data;
}