diff --git a/packages/flutter_tools/lib/src/ios/ios_deploy.dart b/packages/flutter_tools/lib/src/ios/ios_deploy.dart index 0773446676..3df0b71a30 100644 --- a/packages/flutter_tools/lib/src/ios/ios_deploy.dart +++ b/packages/flutter_tools/lib/src/ios/ios_deploy.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'package:meta/meta.dart'; @@ -29,11 +27,11 @@ const String unknownAppLaunchError = 'Error 0xe8000022'; class IOSDeploy { IOSDeploy({ - @required Artifacts artifacts, - @required Cache cache, - @required Logger logger, - @required Platform platform, - @required ProcessManager processManager, + required Artifacts artifacts, + required Cache cache, + required Logger logger, + required Platform platform, + required ProcessManager processManager, }) : _platform = platform, _cache = cache, _processUtils = ProcessUtils(processManager: processManager, logger: logger), @@ -63,8 +61,8 @@ class IOSDeploy { /// /// Uses ios-deploy and returns the exit code. Future uninstallApp({ - @required String deviceId, - @required String bundleId, + required String deviceId, + required String bundleId, }) async { final List launchCommand = [ _binaryPath, @@ -87,11 +85,11 @@ class IOSDeploy { /// /// Uses ios-deploy and returns the exit code. Future installApp({ - @required String deviceId, - @required String bundlePath, - @required Directory appDeltaDirectory, - @required ListlaunchArguments, - @required IOSDeviceConnectionInterface interfaceType, + required String deviceId, + required String bundlePath, + required ListlaunchArguments, + required IOSDeviceConnectionInterface interfaceType, + Directory? appDeltaDirectory, }) async { appDeltaDirectory?.createSync(recursive: true); final List launchCommand = [ @@ -125,11 +123,11 @@ class IOSDeploy { /// This method does not install the app. Call [IOSDeployDebugger.launchAndAttach()] /// to install and attach the debugger to the specified app bundle. IOSDeployDebugger prepareDebuggerForLaunch({ - @required String deviceId, - @required String bundlePath, - @required Directory appDeltaDirectory, - @required List launchArguments, - @required IOSDeviceConnectionInterface interfaceType, + required String deviceId, + required String bundlePath, + required List launchArguments, + required IOSDeviceConnectionInterface interfaceType, + Directory? appDeltaDirectory, }) { appDeltaDirectory?.createSync(recursive: true); // Interactive debug session to support sending the lldb detach command. @@ -167,11 +165,11 @@ class IOSDeploy { /// /// Uses ios-deploy and returns the exit code. Future launchApp({ - @required String deviceId, - @required String bundlePath, - @required Directory appDeltaDirectory, - @required List launchArguments, - @required IOSDeviceConnectionInterface interfaceType, + required String deviceId, + required String bundlePath, + required List launchArguments, + required IOSDeviceConnectionInterface interfaceType, + Directory? appDeltaDirectory, }) async { appDeltaDirectory?.createSync(recursive: true); final List launchCommand = [ @@ -202,8 +200,8 @@ class IOSDeploy { } Future isAppInstalled({ - @required String bundleId, - @required String deviceId, + required String bundleId, + required String deviceId, }) async { final List launchCommand = [ _binaryPath, @@ -244,10 +242,10 @@ enum _IOSDeployDebuggerState { /// Wrapper to launch app and attach the debugger with ios-deploy. class IOSDeployDebugger { IOSDeployDebugger({ - @required Logger logger, - @required ProcessUtils processUtils, - @required List launchCommand, - @required Map iosDeployEnv, + required Logger logger, + required ProcessUtils processUtils, + required List launchCommand, + required Map iosDeployEnv, }) : _processUtils = processUtils, _logger = logger, _launchCommand = launchCommand, @@ -259,8 +257,8 @@ class IOSDeployDebugger { /// Sets the command to "ios-deploy" and environment to an empty map. @visibleForTesting factory IOSDeployDebugger.test({ - @required ProcessManager processManager, - Logger logger, + required ProcessManager processManager, + Logger? logger, }) { final Logger debugLogger = logger ?? BufferLogger.test(); return IOSDeployDebugger( @@ -276,7 +274,7 @@ class IOSDeployDebugger { final List _launchCommand; final Map _iosDeployEnv; - Process _iosDeployProcess; + Process? _iosDeployProcess; Stream get logLines => _debuggerOutput.stream; final StreamController _debuggerOutput = StreamController.broadcast(); @@ -306,8 +304,8 @@ class IOSDeployDebugger { _launchCommand, environment: _iosDeployEnv, ); - String lastLineFromDebugger; - final StreamSubscription stdoutSubscription = _iosDeployProcess.stdout + String? lastLineFromDebugger; + final StreamSubscription stdoutSubscription = _iosDeployProcess!.stdout .transform(utf8.decoder) .transform(const LineSplitter()) .listen((String line) { @@ -346,7 +344,7 @@ class IOSDeployDebugger { _logger.printTrace(line); return; } - if (lastLineFromDebugger != null && lastLineFromDebugger.isNotEmpty && line.isEmpty) { + if (lastLineFromDebugger != null && lastLineFromDebugger!.isNotEmpty && line.isEmpty) { // The lldb console stream from ios-deploy is separated lines by an extra \r\n. // To avoid all lines being double spaced, if the last line from the // debugger was not an empty line, skip this empty line. @@ -356,14 +354,14 @@ class IOSDeployDebugger { } lastLineFromDebugger = line; }); - final StreamSubscription stderrSubscription = _iosDeployProcess.stderr + final StreamSubscription stderrSubscription = _iosDeployProcess!.stderr .transform(utf8.decoder) .transform(const LineSplitter()) .listen((String line) { _monitorIOSDeployFailure(line, _logger); _logger.printTrace(line); }); - unawaited(_iosDeployProcess.exitCode.then((int status) { + unawaited(_iosDeployProcess!.exitCode.then((int status) { _logger.printTrace('ios-deploy exited with code $exitCode'); _debuggerState = _IOSDeployDebuggerState.detached; unawaited(stdoutSubscription.cancel()); @@ -392,7 +390,7 @@ class IOSDeployDebugger { } bool exit() { - final bool success = (_iosDeployProcess == null) || _iosDeployProcess.kill(); + final bool success = (_iosDeployProcess == null) || _iosDeployProcess!.kill(); _iosDeployProcess = null; return success; } @@ -404,7 +402,7 @@ class IOSDeployDebugger { try { // Detach lldb from the app process. - _iosDeployProcess?.stdin?.writeln('process detach'); + _iosDeployProcess?.stdin.writeln('process detach'); _debuggerState = _IOSDeployDebuggerState.detached; } on SocketException catch (error) { // Best effort, try to detach, but maybe the app already exited or already detached. diff --git a/packages/flutter_tools/test/general.shard/ios/ios_deploy_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_deploy_test.dart index b43b41ba20..d3c46b002a 100644 --- a/packages/flutter_tools/test/general.shard/ios/ios_deploy_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/ios_deploy_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'dart:async'; import 'dart:convert'; @@ -22,9 +20,9 @@ import '../../src/fake_process_manager.dart'; import '../../src/fakes.dart'; void main () { - Artifacts artifacts; - String iosDeployPath; - FileSystem fileSystem; + late Artifacts artifacts; + late String iosDeployPath; + late FileSystem fileSystem; setUp(() { artifacts = Artifacts.test(); @@ -86,7 +84,7 @@ void main () { group('IOSDeployDebugger', () { group('launch', () { - BufferLogger logger; + late BufferLogger logger; setUp(() { logger = BufferLogger.test(); @@ -322,7 +320,7 @@ void main () { } IOSDeploy setUpIOSDeploy(ProcessManager processManager, { - Artifacts artifacts, + Artifacts? artifacts, }) { final FakePlatform macPlatform = FakePlatform( operatingSystem: 'macos',