invokeMapMethod<K, V> method
Null safety
- String method,
- [dynamic arguments]
An implementation of invokeMethod that can return typed maps.
Dart generics are reified, meaning that an untyped Map<dynamic, dynamic>
cannot masquerade as a Map<K, V>
. Since invokeMethod can only return
dynamic maps, we instead create a new typed map using Map.cast.
See also:
- invokeMethod, which this call delegates to.
Implementation
Future<Map<K, V>?> invokeMapMethod<K, V>(String method, [ dynamic arguments ]) async {
final Map<dynamic, dynamic>? result = await invokeMethod<Map<dynamic, dynamic>>(method, arguments);
return result?.cast<K, V>();
}