registerExtension function

void registerExtension(String method, ServiceExtensionHandler handler)

Register a ServiceExtensionHandler that will be invoked in this isolate for method. NOTE: Service protocol extensions must be registered in each isolate.

NOTE: method must begin with 'ext.' and you should use the following structure to avoid conflicts with other packages: 'ext.package.command'. That is, immediately following the 'ext.' prefix, should be the registering package name followed by another period ('.') and then the command name. For example: 'ext.dart.io.getOpenFiles'.

Because service extensions are isolate specific, clients using extensions must always include an 'isolateId' parameter with each RPC.

Source

void registerExtension(String method, ServiceExtensionHandler handler) {
  if (method is! String) {
    throw new ArgumentError.value(method, 'method', 'Must be a String');
  }
  if (!method.startsWith('ext.')) {
    throw new ArgumentError.value(method, 'method', 'Must begin with ext.');
  }
  if (_lookupExtension(method) != null) {
    throw new ArgumentError('Extension already registered: $method');
  }
  if (handler is! ServiceExtensionHandler) {
    throw new ArgumentError.value(
        handler, 'handler', 'Must be a ServiceExtensionHandler');
  }
  _registerExtension(method, handler);
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-developer/registerExtension.html