invokeListMethod<T> method

Future<List<T>> invokeListMethod <T>(String method, [ dynamic arguments ])

An implementation of invokeMethod that can return typed lists.

Dart generics are reified, meaning that an untyped List cannot masquerade as a List. Since invokeMethod can only return dynamic maps, 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>();
}