getValue<T> method
T?
getValue<T>(
- M key, [
- T? defaultValue
获取map value
key
map->key
defaultValue
不在存在时返回默认值
Implementation
T? getValue<T>(M key, [T? defaultValue]) {
if (this.isEmptyMap() || !(this?.containsKey(key) ?? false)) {
return defaultValue;
}
Object? obj = this?[key];
if (obj is! T) {
return defaultValue;
}
T result = this?[key] as T;
return result ?? defaultValue;
}