waitForExtension method

Future waitForExtension (
  1. String name
)

Returns a future that completes once the VM service extension RPC with the given name is available.

This works whether the extension is already registered or has yet to be registered.

This is supported as of VM service version 3.1, or Dart SDK version 1.14.

Implementation

Future waitForExtension(String name) async {
  return _scope.getInState(_scope.streams.isolate, () async {
    var extensions = (await load()).extensionRpcs;
    return extensions.contains(name);
  }, (Map json) {
    return json["kind"] == "ServiceExtensionAdded" &&
        json["extensionRPC"] == name;
  }).then((_) => null);
}