checkValid<T> method
Implementation
T checkValid<T>(String key) {
final element = this[key];
if (element == null) {
throw FormatException("Missing key '$key'");
}
if (element is! T) {
throw FormatException(
'Expected element of type $T but got element of type '
'${element.runtimeType}.',
);
}
return element as T;
}