queryVmPidFromUri function

Future<int?> queryVmPidFromUri(
  1. String vmUri
)

Reads the app process PID from the VM service at vmUri.

Runs after launch / attach already saw the VM service come up, so it uses a short timeout (1 s each for connect and getVM) to avoid running far past --timeout when the VM service hangs.

Implementation

Future<int?> queryVmPidFromUri(String vmUri) async {
  final vm = await getVmFromUri(vmUri, timeout: const Duration(seconds: 1));
  return vm?.pid;
}