register static method

String register(
  1. Connection conn, {
  2. String? name,
})

Registers conn so it shows up as a selectable instance in the inspector.

name is the display label (defaults to instance-N). Returns the generated instance id, which you can pass to unregister.

Implementation

static String register(Connection conn, {String? name}) {
  final index = _counter++;
  final id = 'inst-$index';
  _entries[id] = _Entry(id, name ?? 'instance-$index', conn);
  if (!_installed) {
    _installed = true;
    // Best-effort: the registry stays usable even if the VM service is
    // unavailable (e.g. under `dart test`) or the extensions can't install.
    try {
      installServiceExtensions();
    } catch (_) {}
  }
  return id;
}