fix lateinitialization error in devicelab-runner (#94957)
diff --git a/dev/devicelab/bin/tasks/module_test_ios.dart b/dev/devicelab/bin/tasks/module_test_ios.dart
index afd5201..cffc8a7 100644
--- a/dev/devicelab/bin/tasks/module_test_ios.dart
+++ b/dev/devicelab/bin/tasks/module_test_ios.dart
@@ -18,7 +18,9 @@
/// adding Flutter to an existing iOS app.
Future<void> main() async {
await task(() async {
- late String simulatorDeviceId;
+ // this variable cannot be `late`, as we reference it in the `finally` block
+ // which may execute before this field has been initialized
+ String? simulatorDeviceId;
section('Create Flutter module project');
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_module_test.');
diff --git a/dev/devicelab/lib/framework/ios.dart b/dev/devicelab/lib/framework/ios.dart
index 487820c..e0691fc 100644
--- a/dev/devicelab/lib/framework/ios.dart
+++ b/dev/devicelab/lib/framework/ios.dart
@@ -116,14 +116,14 @@
}
/// Shuts down and deletes simulator with deviceId.
-Future<void> removeIOSimulator(String deviceId) async {
+Future<void> removeIOSimulator(String? deviceId) async {
if (deviceId != null && deviceId != '') {
await eval(
'xcrun',
<String>[
'simctl',
'shutdown',
- deviceId
+ deviceId,
],
canFail: true,
workingDirectory: flutterDirectory.path,
@@ -133,7 +133,8 @@
<String>[
'simctl',
'delete',
- deviceId],
+ deviceId,
+ ],
canFail: true,
workingDirectory: flutterDirectory.path,
);