From ada4460502d73625c18cbb54bb6590bf593d9352 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 15 Dec 2022 11:59:34 -0800 Subject: [PATCH] Audit `covariant` usage in tool (#116930) --- .../lib/src/android/android_device.dart | 18 +++++----- .../lib/src/custom_devices/custom_device.dart | 19 +++++----- .../flutter_tools/lib/src/desktop_device.dart | 8 ++--- packages/flutter_tools/lib/src/device.dart | 14 ++++---- .../lib/src/drive/drive_service.dart | 7 ++-- .../lib/src/fuchsia/fuchsia_device.dart | 4 +-- .../flutter_tools/lib/src/ios/devices.dart | 13 +++---- .../flutter_tools/lib/src/ios/simulators.dart | 11 +++--- .../lib/src/linux/linux_device.dart | 3 +- .../lib/src/macos/macos_device.dart | 3 +- .../lib/src/macos/macos_ipad_device.dart | 8 ++--- .../flutter_tools/lib/src/preview_device.dart | 16 ++++----- .../lib/src/proxied_devices/devices.dart | 10 +++--- .../lib/src/resident_runner.dart | 35 ++++++++++--------- .../lib/src/test/integration_test_device.dart | 5 +-- .../lib/src/tester/flutter_tester.dart | 6 ++-- .../flutter_tools/lib/src/web/web_device.dart | 2 +- .../lib/src/windows/windows_device.dart | 3 +- .../commands.shard/hermetic/attach_test.dart | 4 +-- .../commands.shard/hermetic/daemon_test.dart | 5 +-- .../commands.shard/hermetic/install_test.dart | 4 +-- .../hermetic/proxied_devices_test.dart | 4 +-- .../commands.shard/hermetic/run_test.dart | 2 +- .../custom_devices/custom_device_test.dart | 1 + .../general.shard/desktop_device_test.dart | 3 +- .../drive/drive_service_test.dart | 8 ++--- .../test/general.shard/hot_test.dart | 2 +- .../macos/macos_ipad_device_test.dart | 2 +- .../general.shard/resident_runner_test.dart | 4 +-- .../resident_web_runner_cold_test.dart | 4 +-- .../resident_web_runner_test.dart | 4 +-- .../flutter_tools/test/src/fake_devices.dart | 6 ++-- 32 files changed, 120 insertions(+), 118 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index a388672b39bc..964c07845a0c 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -366,7 +366,7 @@ class AndroidDevice extends Device { @override Future isAppInstalled( - AndroidApk app, { + ApplicationPackage app, { String? userIdentifier, }) async { // This call takes 400ms - 600ms. @@ -388,14 +388,14 @@ class AndroidDevice extends Device { } @override - Future isLatestBuildInstalled(AndroidApk app) async { + Future isLatestBuildInstalled(covariant AndroidApk app) async { final String installedSha1 = await _getDeviceApkSha1(app); return installedSha1.isNotEmpty && installedSha1 == _getSourceSha1(app); } @override Future installApp( - AndroidApk app, { + covariant AndroidApk app, { String? userIdentifier, }) async { if (!await _adbIsValid) { @@ -478,7 +478,7 @@ class AndroidDevice extends Device { @override Future uninstallApp( - AndroidApk app, { + ApplicationPackage app, { String? userIdentifier, }) async { if (!await _adbIsValid) { @@ -519,7 +519,7 @@ class AndroidDevice extends Device { @override Future startApp( - AndroidApk package, { + AndroidApk? package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, @@ -721,11 +721,11 @@ class AndroidDevice extends Device { @override Future stopApp( - AndroidApk? app, { + ApplicationPackage? app, { String? userIdentifier, - }) { + }) async { if (app == null) { - return Future.value(false); + return false; } final List command = adbCommandForDevice([ 'shell', @@ -767,7 +767,7 @@ class AndroidDevice extends Device { @override FutureOr getLogReader({ - AndroidApk? app, + ApplicationPackage? app, bool includePastLogs = false, }) async { // The Android log reader isn't app-specific. The `app` parameter isn't used. diff --git a/packages/flutter_tools/lib/src/custom_devices/custom_device.dart b/packages/flutter_tools/lib/src/custom_devices/custom_device.dart index c3bab52e7cee..cfbcf9f67c4c 100644 --- a/packages/flutter_tools/lib/src/custom_devices/custom_device.dart +++ b/packages/flutter_tools/lib/src/custom_devices/custom_device.dart @@ -475,7 +475,7 @@ class CustomDevice extends Device { @override final DevicePortForwarder portForwarder; - CustomDeviceAppSession _getOrCreateAppSession(covariant ApplicationPackage app) { + CustomDeviceAppSession _getOrCreateAppSession(ApplicationPackage app) { return _sessions.putIfAbsent( app, () { @@ -663,7 +663,7 @@ class CustomDevice extends Device { @override FutureOr getLogReader({ - covariant ApplicationPackage? app, + ApplicationPackage? app, bool includePastLogs = false }) { if (app != null) { @@ -674,7 +674,7 @@ class CustomDevice extends Device { } @override - Future installApp(covariant ApplicationPackage app, {String? userIdentifier}) async { + Future installApp(ApplicationPackage app, {String? userIdentifier}) async { final String? appName = app.name; if (appName == null || !await tryUninstall(appName: appName)) { return false; @@ -689,12 +689,12 @@ class CustomDevice extends Device { } @override - Future isAppInstalled(covariant ApplicationPackage app, {String? userIdentifier}) async { + Future isAppInstalled(ApplicationPackage app, {String? userIdentifier}) async { return false; } @override - Future isLatestBuildInstalled(covariant ApplicationPackage app) async { + Future isLatestBuildInstalled(ApplicationPackage app) async { return false; } @@ -742,7 +742,7 @@ class CustomDevice extends Device { @override Future startApp( - covariant ApplicationPackage package, { + ApplicationPackage package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, @@ -796,7 +796,10 @@ class CustomDevice extends Device { } @override - Future stopApp(covariant ApplicationPackage app, {String? userIdentifier}) { + Future stopApp(ApplicationPackage? app, {String? userIdentifier}) async { + if (app == null) { + return false; + } return _getOrCreateAppSession(app).stop(); } @@ -804,7 +807,7 @@ class CustomDevice extends Device { Future get targetPlatform async => _config.platform ?? TargetPlatform.linux_arm64; @override - Future uninstallApp(covariant ApplicationPackage app, {String? userIdentifier}) async { + Future uninstallApp(ApplicationPackage app, {String? userIdentifier}) async { final String? appName = app.name; if (appName == null) { return false; diff --git a/packages/flutter_tools/lib/src/desktop_device.dart b/packages/flutter_tools/lib/src/desktop_device.dart index 351e204bfaf8..c60abbd15c93 100644 --- a/packages/flutter_tools/lib/src/desktop_device.dart +++ b/packages/flutter_tools/lib/src/desktop_device.dart @@ -44,7 +44,7 @@ abstract class DesktopDevice extends Device { final DesktopLogReader _deviceLogReader = DesktopLogReader(); @override - DevFSWriter createDevFSWriter(covariant ApplicationPackage? app, String? userIdentifier) { + DevFSWriter createDevFSWriter(ApplicationPackage? app, String? userIdentifier) { return LocalDevFSWriter(fileSystem: _fileSystem); } @@ -117,7 +117,6 @@ abstract class DesktopDevice extends Device { }) async { if (!prebuiltApplication) { await buildForDevice( - package, buildInfo: debuggingOptions.buildInfo, mainPath: mainPath, ); @@ -179,7 +178,7 @@ abstract class DesktopDevice extends Device { @override Future stopApp( - ApplicationPackage app, { + ApplicationPackage? app, { String? userIdentifier, }) async { bool succeeded = true; @@ -197,8 +196,7 @@ abstract class DesktopDevice extends Device { } /// Builds the current project for this device, with the given options. - Future buildForDevice( - ApplicationPackage package, { + Future buildForDevice({ required BuildInfo buildInfo, String? mainPath, }); diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 63318dfc4ef1..31b19234bf66 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -470,18 +470,18 @@ abstract class Device { /// /// Specify [userIdentifier] to check if installed for a particular user (Android only). Future isAppInstalled( - covariant ApplicationPackage app, { + ApplicationPackage app, { String? userIdentifier, }); /// Check if the latest build of the [app] is already installed. - Future isLatestBuildInstalled(covariant ApplicationPackage app); + Future isLatestBuildInstalled(ApplicationPackage app); /// Install an app package on the current device. /// /// Specify [userIdentifier] to install for a particular user (Android only). Future installApp( - covariant ApplicationPackage app, { + ApplicationPackage app, { String? userIdentifier, }); @@ -490,7 +490,7 @@ abstract class Device { /// Specify [userIdentifier] to uninstall for a particular user, /// defaults to all users (Android only). Future uninstallApp( - covariant ApplicationPackage app, { + ApplicationPackage app, { String? userIdentifier, }); @@ -516,7 +516,7 @@ abstract class Device { /// For example, the desktop device classes can use a writer which /// copies the files across the local file system. DevFSWriter? createDevFSWriter( - covariant ApplicationPackage? app, + ApplicationPackage? app, String? userIdentifier, ) { return null; @@ -531,7 +531,7 @@ abstract class Device { /// reader will also include log messages from before the invocation time. /// Defaults to false. FutureOr getLogReader({ - covariant ApplicationPackage? app, + ApplicationPackage? app, bool includePastLogs = false, }); @@ -583,7 +583,7 @@ abstract class Device { /// /// Specify [userIdentifier] to stop app installed to a profile (Android only). Future stopApp( - covariant ApplicationPackage? app, { + ApplicationPackage? app, { String? userIdentifier, }); diff --git a/packages/flutter_tools/lib/src/drive/drive_service.dart b/packages/flutter_tools/lib/src/drive/drive_service.dart index d96ee4abb8d0..f1df04954e45 100644 --- a/packages/flutter_tools/lib/src/drive/drive_service.dart +++ b/packages/flutter_tools/lib/src/drive/drive_service.dart @@ -296,11 +296,12 @@ class FlutterDriverService extends DriverService { await sharedSkSlWriter(_device!, result, outputFile: writeSkslOnExit, logger: _logger); } // If the application package is available, stop and uninstall. - if (_applicationPackage != null) { - if (!await _device!.stopApp(_applicationPackage, userIdentifier: userIdentifier)) { + final ApplicationPackage? package = _applicationPackage; + if (package != null) { + if (!await _device!.stopApp(package, userIdentifier: userIdentifier)) { _logger.printError('Failed to stop app'); } - if (!await _device!.uninstallApp(_applicationPackage!, userIdentifier: userIdentifier)) { + if (!await _device!.uninstallApp(package, userIdentifier: userIdentifier)) { _logger.printError('Failed to uninstall app'); } } else if (_device!.supportsFlutterExit) { diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart index fb5645e1a69d..60744d4fbea6 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart @@ -293,7 +293,7 @@ class FuchsiaDevice extends Device { @override Future startApp( - covariant FuchsiaApp package, { + FuchsiaApp package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, @@ -471,7 +471,7 @@ class FuchsiaDevice extends Device { @override Future stopApp( - covariant FuchsiaApp app, { + ApplicationPackage? app, { String? userIdentifier, }) async { if (await isSession) { diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index 8e94f5a29f08..b1606e161326 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -8,6 +8,7 @@ import 'package:meta/meta.dart'; import 'package:process/process.dart'; import 'package:vm_service/vm_service.dart' as vm_service; +import '../application_package.dart'; import '../base/file_system.dart'; import '../base/io.dart'; import '../base/logger.dart'; @@ -225,7 +226,7 @@ class IOSDevice extends Device { @override Future isAppInstalled( - IOSApp app, { + ApplicationPackage app, { String? userIdentifier, }) async { bool result; @@ -242,11 +243,11 @@ class IOSDevice extends Device { } @override - Future isLatestBuildInstalled(IOSApp app) async => false; + Future isLatestBuildInstalled(ApplicationPackage app) async => false; @override Future installApp( - IOSApp app, { + covariant IOSApp app, { String? userIdentifier, }) async { final Directory bundle = _fileSystem.directory(app.deviceBundlePath); @@ -280,7 +281,7 @@ class IOSDevice extends Device { @override Future uninstallApp( - IOSApp app, { + ApplicationPackage app, { String? userIdentifier, }) async { int uninstallationResult; @@ -434,7 +435,7 @@ class IOSDevice extends Device { @override Future stopApp( - IOSApp app, { + ApplicationPackage? app, { String? userIdentifier, }) async { // If the debugger is not attached, killing the ios-deploy process won't stop the app. @@ -453,7 +454,7 @@ class IOSDevice extends Device { @override DeviceLogReader getLogReader({ - IOSApp? app, + covariant IOSApp? app, bool includePastLogs = false, }) { assert(!includePastLogs, 'Past log reading not supported on iOS devices.'); diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index 6da27e7c4cda..f3e392b4461e 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -327,7 +327,7 @@ class IOSSimulator extends Device { final SimControl _simControl; @override - DevFSWriter createDevFSWriter(covariant ApplicationPackage? app, String? userIdentifier) { + DevFSWriter createDevFSWriter(ApplicationPackage? app, String? userIdentifier) { return LocalDevFSWriter(fileSystem: globals.fs); } @@ -369,8 +369,7 @@ class IOSSimulator extends Device { String? userIdentifier, }) async { try { - final IOSApp iosApp = app; - await _simControl.install(id, iosApp.simulatorBundlePath); + await _simControl.install(id, app.simulatorBundlePath); return true; } on Exception { return false; @@ -420,7 +419,7 @@ class IOSSimulator extends Device { @override Future startApp( - covariant IOSApp package, { + IOSApp package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, @@ -506,7 +505,7 @@ class IOSSimulator extends Device { return LaunchResult.failed(); } - Future _setupUpdatedApplicationBundle(covariant BuildableIOSApp app, BuildInfo buildInfo, String? mainPath) async { + Future _setupUpdatedApplicationBundle(BuildableIOSApp app, BuildInfo buildInfo, String? mainPath) async { // Step 1: Build the Xcode project. // The build mode for the simulator is always debug. assert(buildInfo.isDebug); @@ -574,7 +573,7 @@ class IOSSimulator extends Device { @override DeviceLogReader getLogReader({ - IOSApp? app, + covariant IOSApp? app, bool includePastLogs = false, }) { assert(!includePastLogs, 'Past log reading not supported on iOS simulators.'); diff --git a/packages/flutter_tools/lib/src/linux/linux_device.dart b/packages/flutter_tools/lib/src/linux/linux_device.dart index 8c0a06598b9f..b017389bc637 100644 --- a/packages/flutter_tools/lib/src/linux/linux_device.dart +++ b/packages/flutter_tools/lib/src/linux/linux_device.dart @@ -57,8 +57,7 @@ class LinuxDevice extends DesktopDevice { } @override - Future buildForDevice( - covariant LinuxApp package, { + Future buildForDevice({ String? mainPath, required BuildInfo buildInfo, }) async { diff --git a/packages/flutter_tools/lib/src/macos/macos_device.dart b/packages/flutter_tools/lib/src/macos/macos_device.dart index c0a49a7e6fea..8ed98fa7588c 100644 --- a/packages/flutter_tools/lib/src/macos/macos_device.dart +++ b/packages/flutter_tools/lib/src/macos/macos_device.dart @@ -65,8 +65,7 @@ class MacOSDevice extends DesktopDevice { } @override - Future buildForDevice( - covariant MacOSApp package, { + Future buildForDevice({ required BuildInfo buildInfo, String? mainPath, }) async { diff --git a/packages/flutter_tools/lib/src/macos/macos_ipad_device.dart b/packages/flutter_tools/lib/src/macos/macos_ipad_device.dart index eb2331db9d66..535843629084 100644 --- a/packages/flutter_tools/lib/src/macos/macos_ipad_device.dart +++ b/packages/flutter_tools/lib/src/macos/macos_ipad_device.dart @@ -14,7 +14,6 @@ import '../base/platform.dart'; import '../build_info.dart'; import '../desktop_device.dart'; import '../device.dart'; -import '../ios/application_package.dart'; import '../ios/ios_workflow.dart'; import '../project.dart'; @@ -59,7 +58,7 @@ class MacOSDesignedForIPadDevice extends DesktopDevice { @override Future startApp( - IOSApp package, { + ApplicationPackage? package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, @@ -74,13 +73,12 @@ class MacOSDesignedForIPadDevice extends DesktopDevice { @override Future stopApp( - IOSApp app, { + ApplicationPackage? app, { String? userIdentifier, }) async => false; @override - Future buildForDevice( - covariant IOSApp package, { + Future buildForDevice({ String? mainPath, required BuildInfo buildInfo, }) async { diff --git a/packages/flutter_tools/lib/src/preview_device.dart b/packages/flutter_tools/lib/src/preview_device.dart index c37a55cdfb6a..9c2a7bb6cda0 100644 --- a/packages/flutter_tools/lib/src/preview_device.dart +++ b/packages/flutter_tools/lib/src/preview_device.dart @@ -65,16 +65,16 @@ class PreviewDevice extends Device { final DesktopLogReader _logReader = DesktopLogReader(); @override - FutureOr getLogReader({covariant ApplicationPackage? app, bool includePastLogs = false}) => _logReader; + FutureOr getLogReader({ApplicationPackage? app, bool includePastLogs = false}) => _logReader; @override - Future installApp(covariant ApplicationPackage? app, {String? userIdentifier}) async => true; + Future installApp(ApplicationPackage? app, {String? userIdentifier}) async => true; @override - Future isAppInstalled(covariant ApplicationPackage app, {String? userIdentifier}) async => false; + Future isAppInstalled(ApplicationPackage app, {String? userIdentifier}) async => false; @override - Future isLatestBuildInstalled(covariant ApplicationPackage app) async => false; + Future isLatestBuildInstalled(ApplicationPackage app) async => false; @override Future get isLocalEmulator async => false; @@ -97,7 +97,7 @@ class PreviewDevice extends Device { Process? _process; @override - Future startApp(covariant ApplicationPackage package, { + Future startApp(ApplicationPackage? package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, @@ -163,7 +163,7 @@ class PreviewDevice extends Device { } @override - Future stopApp(covariant ApplicationPackage app, {String? userIdentifier}) async { + Future stopApp(ApplicationPackage? app, {String? userIdentifier}) async { return _process?.kill() ?? false; } @@ -176,12 +176,12 @@ class PreviewDevice extends Device { } @override - Future uninstallApp(covariant ApplicationPackage app, {String? userIdentifier}) async { + Future uninstallApp(ApplicationPackage app, {String? userIdentifier}) async { return true; } @override - DevFSWriter createDevFSWriter(covariant ApplicationPackage? app, String? userIdentifier) { + DevFSWriter createDevFSWriter(ApplicationPackage? app, String? userIdentifier) { return LocalDevFSWriter(fileSystem: _fileSystem); } } diff --git a/packages/flutter_tools/lib/src/proxied_devices/devices.dart b/packages/flutter_tools/lib/src/proxied_devices/devices.dart index dfd8ce2bd6ea..2f6bed2d796c 100644 --- a/packages/flutter_tools/lib/src/proxied_devices/devices.dart +++ b/packages/flutter_tools/lib/src/proxied_devices/devices.dart @@ -172,22 +172,22 @@ class ProxiedDevice extends Device { @override Future isAppInstalled( - covariant ApplicationPackage app, { + ApplicationPackage app, { String? userIdentifier, }) => throw UnimplementedError(); @override - Future isLatestBuildInstalled(covariant ApplicationPackage app) => throw UnimplementedError(); + Future isLatestBuildInstalled(ApplicationPackage app) => throw UnimplementedError(); @override Future installApp( - covariant ApplicationPackage app, { + ApplicationPackage app, { String? userIdentifier, }) => throw UnimplementedError(); @override Future uninstallApp( - covariant ApplicationPackage app, { + ApplicationPackage app, { String? userIdentifier, }) => throw UnimplementedError(); @@ -224,7 +224,7 @@ class ProxiedDevice extends Device { @override Future startApp( - covariant PrebuiltApplicationPackage package, { + PrebuiltApplicationPackage package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index c30209a92467..0ab91c700a50 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -424,8 +424,9 @@ class FlutterDevice { buildInfo: hotRunner.debuggingOptions.buildInfo, applicationBinary: hotRunner.applicationBinary, ); + final ApplicationPackage? applicationPackage = package; - if (package == null) { + if (applicationPackage == null) { String message = 'No application found for $targetPlatform.'; final String? hint = await getMissingPackageHintForPlatform(targetPlatform); if (hint != null) { @@ -434,7 +435,7 @@ class FlutterDevice { globals.printError(message); return 1; } - devFSWriter = device!.createDevFSWriter(package, userIdentifier); + devFSWriter = device!.createDevFSWriter(applicationPackage, userIdentifier); final Map platformArgs = { 'multidex': hotRunner.multidexEnabled, @@ -444,7 +445,7 @@ class FlutterDevice { // Start the application. final Future futureResult = device!.startApp( - package, + applicationPackage, mainPath: hotRunner.mainPath, debuggingOptions: hotRunner.debuggingOptions, platformArgs: platformArgs, @@ -483,14 +484,26 @@ class FlutterDevice { buildInfo: coldRunner.debuggingOptions.buildInfo, applicationBinary: coldRunner.applicationBinary, ); - devFSWriter = device!.createDevFSWriter(package, userIdentifier); + final ApplicationPackage? applicationPackage = package; + + if (applicationPackage == null) { + String message = 'No application found for $targetPlatform.'; + final String? hint = await getMissingPackageHintForPlatform(targetPlatform); + if (hint != null) { + message += '\n$hint'; + } + globals.printError(message); + return 1; + } + + devFSWriter = device!.createDevFSWriter(applicationPackage, userIdentifier); final String modeName = coldRunner.debuggingOptions.buildInfo.friendlyModeName; final bool prebuiltMode = coldRunner.applicationBinary != null; if (coldRunner.mainPath == null) { assert(prebuiltMode); globals.printStatus( - 'Launching ${package!.displayName} ' + 'Launching ${applicationPackage.displayName} ' 'on ${device!.name} in $modeName mode...', ); } else { @@ -500,16 +513,6 @@ class FlutterDevice { ); } - if (package == null) { - String message = 'No application found for $targetPlatform.'; - final String? hint = await getMissingPackageHintForPlatform(targetPlatform); - if (hint != null) { - message += '\n$hint'; - } - globals.printError(message); - return 1; - } - final Map platformArgs = {}; if (coldRunner.traceStartup != null) { platformArgs['trace-startup'] = coldRunner.traceStartup; @@ -519,7 +522,7 @@ class FlutterDevice { await startEchoingDeviceLog(); final LaunchResult result = await device!.startApp( - package, + applicationPackage, mainPath: coldRunner.mainPath, debuggingOptions: coldRunner.debuggingOptions, platformArgs: platformArgs, diff --git a/packages/flutter_tools/lib/src/test/integration_test_device.dart b/packages/flutter_tools/lib/src/test/integration_test_device.dart index cdf1dbd70bef..49930901ceb2 100644 --- a/packages/flutter_tools/lib/src/test/integration_test_device.dart +++ b/packages/flutter_tools/lib/src/test/integration_test_device.dart @@ -47,12 +47,13 @@ class IntegrationTestTestDevice implements TestDevice { targetPlatform, buildInfo: debuggingOptions.buildInfo, ); - if (_applicationPackage == null) { + final ApplicationPackage? package = _applicationPackage; + if (package == null) { throw TestDeviceException('No application found for $targetPlatform.', StackTrace.current); } final LaunchResult launchResult = await device.startApp( - _applicationPackage, + package, mainPath: entrypointPath, platformArgs: {}, debuggingOptions: debuggingOptions, diff --git a/packages/flutter_tools/lib/src/tester/flutter_tester.dart b/packages/flutter_tools/lib/src/tester/flutter_tester.dart index 01998441e192..162370f9f06b 100644 --- a/packages/flutter_tools/lib/src/tester/flutter_tester.dart +++ b/packages/flutter_tools/lib/src/tester/flutter_tester.dart @@ -130,7 +130,7 @@ class FlutterTesterDevice extends Device { @override Future startApp( - ApplicationPackage package, { + ApplicationPackage? package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, @@ -217,7 +217,7 @@ class FlutterTesterDevice extends Device { @override Future stopApp( - ApplicationPackage app, { + ApplicationPackage? app, { String? userIdentifier, }) async { _process?.kill(); @@ -236,7 +236,7 @@ class FlutterTesterDevice extends Device { @override DevFSWriter createDevFSWriter( - covariant ApplicationPackage app, + ApplicationPackage? app, String? userIdentifier, ) { return LocalDevFSWriter( diff --git a/packages/flutter_tools/lib/src/web/web_device.dart b/packages/flutter_tools/lib/src/web/web_device.dart index 8e46efb61f37..467c4ce9f93d 100644 --- a/packages/flutter_tools/lib/src/web/web_device.dart +++ b/packages/flutter_tools/lib/src/web/web_device.dart @@ -118,7 +118,7 @@ abstract class ChromiumDevice extends Device { @override Future startApp( - WebApplicationPackage? package, { + ApplicationPackage? package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, diff --git a/packages/flutter_tools/lib/src/windows/windows_device.dart b/packages/flutter_tools/lib/src/windows/windows_device.dart index 83af4e012dbd..8be33169331b 100644 --- a/packages/flutter_tools/lib/src/windows/windows_device.dart +++ b/packages/flutter_tools/lib/src/windows/windows_device.dart @@ -49,8 +49,7 @@ class WindowsDevice extends DesktopDevice { } @override - Future buildForDevice( - covariant WindowsApp package, { + Future buildForDevice({ String? mainPath, required BuildInfo buildInfo, }) async { diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart index e6e3526d4eb9..a725c0b1b1f8 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart @@ -6,7 +6,7 @@ import 'dart:async'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/android_device.dart'; -import 'package:flutter_tools/src/android/application_package.dart'; +import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/dds.dart'; @@ -947,7 +947,7 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { @override FutureOr getLogReader({ - AndroidApk? app, + ApplicationPackage? app, bool includePastLogs = false, }) { if (onGetLogReader == null) { diff --git a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart index fa2958726abb..c196ac0f21bc 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart @@ -886,15 +886,16 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { late DeviceLogReader logReader; @override FutureOr getLogReader({ - covariant ApplicationPackage? app, + ApplicationPackage? app, bool includePastLogs = false, }) => logReader; ApplicationPackage? startAppPackage; late LaunchResult launchResult; + @override Future startApp( - ApplicationPackage package, { + ApplicationPackage? package, { String? mainPath, String? route, DebuggingOptions? debuggingOptions, diff --git a/packages/flutter_tools/test/commands.shard/hermetic/install_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/install_test.dart index 6b3309f3ad75..0305c95fa215 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/install_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/install_test.dart @@ -148,7 +148,7 @@ class FakeIOSDevice extends Fake implements IOSDevice { @override Future isAppInstalled( - IOSApp app, { + ApplicationPackage app, { String? userIdentifier, }) async => false; @@ -168,7 +168,7 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { @override Future isAppInstalled( - AndroidApk app, { + ApplicationPackage app, { String? userIdentifier, }) async => false; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/proxied_devices_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/proxied_devices_test.dart index 3630cc3546c6..a77e516a45ec 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/proxied_devices_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/proxied_devices_test.dart @@ -302,7 +302,7 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { late DeviceLogReader logReader; @override FutureOr getLogReader({ - covariant ApplicationPackage? app, + ApplicationPackage? app, bool includePastLogs = false, }) => logReader; @@ -310,7 +310,7 @@ class FakeAndroidDevice extends Fake implements AndroidDevice { late LaunchResult launchResult; @override Future startApp( - ApplicationPackage package, { + ApplicationPackage? package, { String? mainPath, String? route, DebuggingOptions? debuggingOptions, diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart index 930d1dbba80e..55ed661e6301 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart @@ -990,7 +990,7 @@ class FakeDevice extends Fake implements Device { @override DevFSWriter? createDevFSWriter( - covariant ApplicationPackage? app, + ApplicationPackage? app, String? userIdentifier, ) { return null; diff --git a/packages/flutter_tools/test/general.shard/custom_devices/custom_device_test.dart b/packages/flutter_tools/test/general.shard/custom_devices/custom_device_test.dart index 971eb9f1c85e..56e70f2afcc7 100644 --- a/packages/flutter_tools/test/general.shard/custom_devices/custom_device_test.dart +++ b/packages/flutter_tools/test/general.shard/custom_devices/custom_device_test.dart @@ -137,6 +137,7 @@ void main() { expect(await device.isLatestBuildInstalled(linuxApp), false); expect(await device.isAppInstalled(linuxApp), false); expect(await device.stopApp(linuxApp), false); + expect(await device.stopApp(null), false); expect(device.category, Category.mobile); expect(device.supportsRuntimeMode(BuildMode.debug), true); diff --git a/packages/flutter_tools/test/general.shard/desktop_device_test.dart b/packages/flutter_tools/test/general.shard/desktop_device_test.dart index bd19c1b8956a..449b40f88c57 100644 --- a/packages/flutter_tools/test/general.shard/desktop_device_test.dart +++ b/packages/flutter_tools/test/general.shard/desktop_device_test.dart @@ -357,8 +357,7 @@ class FakeDesktopDevice extends DesktopDevice { bool isSupportedForProject(FlutterProject flutterProject) => true; @override - Future buildForDevice( - ApplicationPackage package, { + Future buildForDevice({ String? mainPath, BuildInfo? buildInfo, }) async { diff --git a/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart b/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart index b6471f03e6a8..2d80f96c25bc 100644 --- a/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart +++ b/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart @@ -503,13 +503,13 @@ class FakeDevice extends Fake implements Device { @override Future getLogReader({ - covariant ApplicationPackage? app, + ApplicationPackage? app, bool includePastLogs = false, }) async => NoOpDeviceLogReader('test'); @override Future startApp( - covariant ApplicationPackage package, { + ApplicationPackage? package, { String? mainPath, String? route, required DebuggingOptions debuggingOptions, @@ -526,13 +526,13 @@ class FakeDevice extends Fake implements Device { } @override - Future stopApp(covariant ApplicationPackage app, {String? userIdentifier}) async { + Future stopApp(ApplicationPackage? app, {String? userIdentifier}) async { didStopApp = true; return true; } @override - Future uninstallApp(covariant ApplicationPackage app, {String? userIdentifier}) async { + Future uninstallApp(ApplicationPackage app, {String? userIdentifier}) async { didUninstallApp = true; return true; } diff --git a/packages/flutter_tools/test/general.shard/hot_test.dart b/packages/flutter_tools/test/general.shard/hot_test.dart index 721032efb9eb..7c1f3b986a6d 100644 --- a/packages/flutter_tools/test/general.shard/hot_test.dart +++ b/packages/flutter_tools/test/general.shard/hot_test.dart @@ -607,7 +607,7 @@ class FakeDevice extends Fake implements Device { @override Future stopApp( - covariant ApplicationPackage? app, { + ApplicationPackage? app, { String? userIdentifier, }) async { return true; diff --git a/packages/flutter_tools/test/general.shard/macos/macos_ipad_device_test.dart b/packages/flutter_tools/test/general.shard/macos/macos_ipad_device_test.dart index 6b8a2eb85e4c..b5a9aafb71b7 100644 --- a/packages/flutter_tools/test/general.shard/macos/macos_ipad_device_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/macos_ipad_device_test.dart @@ -141,7 +141,7 @@ void main() { ), throwsA(isA()), ); - await expectLater(() => device.buildForDevice(FakeIOSApp(), buildInfo: BuildInfo.debug), throwsA(isA())); + await expectLater(() => device.buildForDevice(buildInfo: BuildInfo.debug), throwsA(isA())); expect(device.executablePathForDevice(FakeIOSApp(), BuildMode.debug), null); }); } diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart index eea8f9b3798c..67747d490e0b 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -2649,7 +2649,7 @@ class FakeDevice extends Fake implements Device { } @override - Future stopApp(covariant ApplicationPackage? app, {String? userIdentifier}) async { + Future stopApp(ApplicationPackage? app, {String? userIdentifier}) async { appStopped = true; return true; } @@ -2664,7 +2664,7 @@ class FakeDevice extends Fake implements Device { @override FutureOr getLogReader({ - covariant ApplicationPackage? app, + ApplicationPackage? app, bool includePastLogs = false, }) => NoOpDeviceLogReader(name); diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart index f4352e5780e2..60206c2da2a7 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart @@ -189,7 +189,7 @@ class FakeWebDevice extends Fake implements Device { @override Future stopApp( - covariant ApplicationPackage? app, { + ApplicationPackage? app, { String? userIdentifier, }) async { return true; @@ -197,7 +197,7 @@ class FakeWebDevice extends Fake implements Device { @override Future startApp( - covariant ApplicationPackage? package, { + ApplicationPackage? package, { String? mainPath, String? route, DebuggingOptions? debuggingOptions, diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index 48580fc2007e..3d3c5db10607 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -1273,7 +1273,7 @@ class FakeDevice extends Fake implements Device { @override Future startApp( - covariant ApplicationPackage? package, { + ApplicationPackage? package, { String? mainPath, String? route, DebuggingOptions? debuggingOptions, @@ -1287,7 +1287,7 @@ class FakeDevice extends Fake implements Device { @override Future stopApp( - covariant ApplicationPackage? app, { + ApplicationPackage? app, { String? userIdentifier, }) async { if (count > 0) { diff --git a/packages/flutter_tools/test/src/fake_devices.dart b/packages/flutter_tools/test/src/fake_devices.dart index 7109d998a5fa..d19cf4a3399e 100644 --- a/packages/flutter_tools/test/src/fake_devices.dart +++ b/packages/flutter_tools/test/src/fake_devices.dart @@ -82,7 +82,7 @@ class FakeDevice extends Device { final String name; @override - Future startApp(covariant ApplicationPackage package, { + Future startApp(ApplicationPackage? package, { String? mainPath, String? route, DebuggingOptions? debuggingOptions, @@ -93,13 +93,13 @@ class FakeDevice extends Device { }) async => _launchResult; @override - Future stopApp(covariant ApplicationPackage app, { + Future stopApp(ApplicationPackage? app, { String? userIdentifier, }) async => true; @override Future uninstallApp( - covariant ApplicationPackage app, { + ApplicationPackage app, { String? userIdentifier, }) async => true;