IMap<K, V>.fromMap constructor
IMap<K, V>.fromMap (
- Map<
K, V> other
Creates an IMap with the same keys and values as other.
other must be of type Map<Guid, Object?>, Map<String, Object?>,
or Map<String, String>.
Implementation
factory IMap.fromMap(Map<K, V> other) {
if (isSameType<K, Guid>() && isSimilarType<V, Object>()) {
final iMap = MediaPropertySet();
other.cast<Guid, Object?>().forEach(iMap.insert);
return IMap.fromRawPointer(iMap.ptr,
iterableIid: IID_IIterable_IKeyValuePair_Guid_Object);
}
if (isSameType<K, String>()) {
if (isSameType<V, String>()) {
final iMap = StringMap();
other.cast<String, String>().forEach(iMap.insert);
return IMap.fromRawPointer(iMap.ptr,
iterableIid: IID_IIterable_IKeyValuePair_String_String);
}
if (isSimilarType<V, Object>()) {
final iMap = PropertySet();
other.cast<String, Object?>().forEach(iMap.insert);
return IMap.fromRawPointer(iMap.ptr,
iterableIid: IID_IIterable_IKeyValuePair_String_Object);
}
}
throw ArgumentError.value(other, 'other', 'Unsupported map');
}