fix lateinitialization error in devicelab-runner (#94957)

This commit is contained in:
Christopher Fujino 2021-12-28 18:19:16 -08:00 committed by GitHub
parent 2d2cd1f5c0
commit 6054eda86b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -18,7 +18,9 @@ import 'package:path/path.dart' as path;
/// 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.');

View File

@ -116,14 +116,14 @@ Future<void> testWithNewIOSSimulator(
}
/// 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 @@ Future<void> removeIOSimulator(String deviceId) async {
<String>[
'simctl',
'delete',
deviceId],
deviceId,
],
canFail: true,
workingDirectory: flutterDirectory.path,
);