asMap<E> method
Implementation
E asMap<E>(String key) {
if (_map is! E) {
throw const DartSuiPluginException(
'Invalid map casting. only use `asMap` method for casting Map<String,dynamic>.');
}
final Map? value = as(key);
if (value == null) {
if (null is E) {
return null as E;
}
throw DartSuiPluginException('Key not found.',
details: {'key': key, 'data': this});
}
try {
return value.cast<String, dynamic>() as E;
} on TypeError {
throw DartSuiPluginException('Incorrect value.', details: {
'key': key,
'expected': '$E',
'value': value.runtimeType,
'data': this
});
}
}