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