invokeListMethod<T> method

Future<List<T>?> invokeListMethod<T>(
  1. String method, [
  2. 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:

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>();
}