shutdown method
Shut down a device: simctl shutdown (iOS) / adb emu kill (Android); null on success.
Implementation
Future<String?> shutdown(DevicePlatform platform, String deviceId, {String adbPath = 'adb'}) async {
await ProcessRegistry.instance.stopDevice(deviceId, all: true);
try {
final r = platform == DevicePlatform.ios
? await runBounded('xcrun', ['simctl', 'shutdown', deviceId],
timeout: const Duration(seconds: 60), phase: 'simctl shutdown')
: await runBounded(adbPath, ['-s', deviceId, 'emu', 'kill'],
timeout: const Duration(seconds: 10), phase: 'adb emu kill');
if (r.exitCode != 0) {
final err = ((r.stderr as String?) ?? '').trim();
if (err.contains('current state: Shutdown')) return null; // already off
return err.isEmpty ? 'exit ${r.exitCode}' : err;
}
return null;
} on Object catch (e) {
return '$e';
}
}