callExtensionOrNull method

Future<Map<String, Object?>?> callExtensionOrNull(
  1. String method,
  2. Map<String, String> args, {
  3. Duration? timeout,
})

Calls service extension method in the Flutter isolate; null when the isolate has not registered it.

Implementation

Future<Map<String, Object?>?> callExtensionOrNull(String method, Map<String, String> args,
    {Duration? timeout}) async {
  try {
    final resp = await _guard(() => _vm.service.callServiceExtension(method, isolateId: flutterIsolateId, args: args),
        op: method, timeout: timeout);
    return resp.json?.cast<String, Object?>();
  } on RPCError catch (e) {
    if (e.code == -32601 || e.message.contains('not found')) return null;
    rethrow;
  }
}