safeAsMap<T, V> method
Implementation
Map<T, V>? safeAsMap<T, V>() {
if (this is Map) {
var origin = this as Map;
if (origin.isEmpty) {
return <T, V>{};
}
var realMap = <T, V>{};
origin.forEach((key, value) {
if (key is T && value is V) {
realMap[key] = value;
}
});
return realMap;
} else {
return null;
}
}