diff --git a/packages/flutter_tools/lib/src/desktop_device.dart b/packages/flutter_tools/lib/src/desktop_device.dart index 2e4eabe852..c9f7e1de5d 100644 --- a/packages/flutter_tools/lib/src/desktop_device.dart +++ b/packages/flutter_tools/lib/src/desktop_device.dart @@ -203,8 +203,8 @@ abstract class DesktopDevice extends Device { /// Builds the current project for this device, with the given options. Future buildForDevice( ApplicationPackage package, { + required BuildInfo buildInfo, String? mainPath, - BuildInfo buildInfo, }); /// Returns the path to the executable to run for [package] on this device for diff --git a/packages/flutter_tools/lib/src/macos/macos_device.dart b/packages/flutter_tools/lib/src/macos/macos_device.dart index 51b274d655..405202ad4f 100644 --- a/packages/flutter_tools/lib/src/macos/macos_device.dart +++ b/packages/flutter_tools/lib/src/macos/macos_device.dart @@ -2,9 +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 'package:meta/meta.dart'; import 'package:process/process.dart'; import '../base/file_system.dart'; @@ -23,10 +20,10 @@ import 'macos_workflow.dart'; /// A device that represents a desktop MacOS target. class MacOSDevice extends DesktopDevice { MacOSDevice({ - @required ProcessManager processManager, - @required Logger logger, - @required FileSystem fileSystem, - @required OperatingSystemUtils operatingSystemUtils, + required ProcessManager processManager, + required Logger logger, + required FileSystem fileSystem, + required OperatingSystemUtils operatingSystemUtils, }) : _processManager = processManager, _logger = logger, _operatingSystemUtils = operatingSystemUtils, @@ -70,8 +67,8 @@ class MacOSDevice extends DesktopDevice { @override Future buildForDevice( covariant MacOSApp package, { - String mainPath, - BuildInfo buildInfo, + required BuildInfo buildInfo, + String? mainPath, }) async { await buildMacOS( flutterProject: FlutterProject.current(), @@ -82,7 +79,7 @@ class MacOSDevice extends DesktopDevice { } @override - String executablePathForDevice(covariant MacOSApp package, BuildMode buildMode) { + String? executablePathForDevice(covariant MacOSApp package, BuildMode buildMode) { return package.executable(buildMode); } @@ -92,8 +89,13 @@ class MacOSDevice extends DesktopDevice { // than post-attach, since this won't run for release builds, but there's // no general-purpose way of knowing when a process is far enough along in // the launch process for 'open' to foreground it. + final String? applicationBundle = package.applicationBundle(buildMode); + if (applicationBundle == null) { + _logger.printError('Failed to foreground app; application bundle not found'); + return; + } _processManager.run([ - 'open', package.applicationBundle(buildMode), + 'open', applicationBundle, ]).then((ProcessResult result) { if (result.exitCode != 0) { _logger.printError('Failed to foreground app; open returned ${result.exitCode}'); @@ -104,12 +106,12 @@ class MacOSDevice extends DesktopDevice { class MacOSDevices extends PollingDeviceDiscovery { MacOSDevices({ - @required Platform platform, - @required MacOSWorkflow macOSWorkflow, - @required ProcessManager processManager, - @required Logger logger, - @required FileSystem fileSystem, - @required OperatingSystemUtils operatingSystemUtils, + required Platform platform, + required MacOSWorkflow macOSWorkflow, + required ProcessManager processManager, + required Logger logger, + required FileSystem fileSystem, + required OperatingSystemUtils operatingSystemUtils, }) : _logger = logger, _platform = platform, _macOSWorkflow = macOSWorkflow, @@ -132,7 +134,7 @@ class MacOSDevices extends PollingDeviceDiscovery { bool get canListAnything => _macOSWorkflow.canListDevices; @override - Future> pollingGetDevices({ Duration timeout }) async { + Future> pollingGetDevices({ Duration? timeout }) async { if (!canListAnything) { return const []; } diff --git a/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart b/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart index fd5f4da1ef..fba1bc5fda 100644 --- a/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/macos_device_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 'package:file/memory.dart';