readLaunchPid function

String readLaunchPid()

Reads the app or flutter-tools PID written during launch.

Returns an empty string until one of the expected PID files exists.

Implementation

String readLaunchPid() {
  for (final path in [appPidFile, pidFile]) {
    final file = File(path);
    if (!file.existsSync()) {
      continue;
    }

    final pid = file.readAsStringSync().trim();
    if (pid.isNotEmpty) {
      return pid;
    }
  }

  return '';
}