attachRequest method

  1. @override
Future<void> attachRequest(
  1. Request request,
  2. TA args,
  3. void sendResponse()
)

attachRequest is called by the client when it wants us to attach to an existing app. This will only be called once (and only one of this or launchRequest will be called).

Implementation

@override
Future<void> attachRequest(
  Request request,
  TA args,
  void Function() sendResponse,
) async {
  try {
    this.args = args as DartCommonLaunchAttachRequestArguments;
    isAttach = true;
    _subscribeToOutputStreams = true;

    // Common setup.
    await _prepareForLaunchOrAttach(null);

    // Delegate to the sub-class to attach to the process.
    await attachImpl();

    sendResponse();
  } on DebugAdapterException catch (e) {
    // Any errors that are thrown as part of an AttachRequest should be shown
    // to the user.
    throw DebugAdapterException(e.message, showToUser: true);
  }
}