connect method

Future<void> connect(
  1. Uri uri, {
  2. void onError(
    1. Object,
    2. StackTrace?
    )?,
})

Sets the Dart Tooling Daemon connection to point to uri.

Before connecting to uri, if a current connection exists, then disconnect is called to close it.

Implementation

Future<void> connect(
  Uri uri, {
  void Function(Object, StackTrace?)? onError,
}) async {
  await disconnect();

  try {
    _connection.value = await DartToolingDaemon.connect(uri);
    _uri = uri;
    _log.info('Successfully connected to DTD at: $uri');
  } catch (e, st) {
    onError?.call(e, st);
  }
}