LinkedHashMap<K, V>.from 构造函数
- Map other
创建一个包含 other
中所有键值对的 LinkedHashMap。
键必须是 K
的实例,值必须是 V
。other
映射可以是任何类型。示例
final baseMap = <num, Object>{1: 'A', 2: 'B', 3: 'C'};
final fromBaseMap = LinkedHashMap<int, String>.from(baseMap);
print(fromBaseMap); // {1: A, 2: B, 3: C}
实现
factory LinkedHashMap.from(Map<dynamic, dynamic> other) {
LinkedHashMap<K, V> result = LinkedHashMap<K, V>();
other.forEach((dynamic k, dynamic v) {
result[k as K] = v as V;
});
return result;
}