feat: migrate macos/macos_device.dart to null safety (#92633)
This commit is contained in:
parent
c3ad4f0f66
commit
41167c957d
@ -203,8 +203,8 @@ abstract class DesktopDevice extends Device {
|
|||||||
/// Builds the current project for this device, with the given options.
|
/// Builds the current project for this device, with the given options.
|
||||||
Future<void> buildForDevice(
|
Future<void> buildForDevice(
|
||||||
ApplicationPackage package, {
|
ApplicationPackage package, {
|
||||||
|
required BuildInfo buildInfo,
|
||||||
String? mainPath,
|
String? mainPath,
|
||||||
BuildInfo buildInfo,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Returns the path to the executable to run for [package] on this device for
|
/// Returns the path to the executable to run for [package] on this device for
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
import 'package:process/process.dart';
|
import 'package:process/process.dart';
|
||||||
|
|
||||||
import '../base/file_system.dart';
|
import '../base/file_system.dart';
|
||||||
@ -23,10 +20,10 @@ import 'macos_workflow.dart';
|
|||||||
/// A device that represents a desktop MacOS target.
|
/// A device that represents a desktop MacOS target.
|
||||||
class MacOSDevice extends DesktopDevice {
|
class MacOSDevice extends DesktopDevice {
|
||||||
MacOSDevice({
|
MacOSDevice({
|
||||||
@required ProcessManager processManager,
|
required ProcessManager processManager,
|
||||||
@required Logger logger,
|
required Logger logger,
|
||||||
@required FileSystem fileSystem,
|
required FileSystem fileSystem,
|
||||||
@required OperatingSystemUtils operatingSystemUtils,
|
required OperatingSystemUtils operatingSystemUtils,
|
||||||
}) : _processManager = processManager,
|
}) : _processManager = processManager,
|
||||||
_logger = logger,
|
_logger = logger,
|
||||||
_operatingSystemUtils = operatingSystemUtils,
|
_operatingSystemUtils = operatingSystemUtils,
|
||||||
@ -70,8 +67,8 @@ class MacOSDevice extends DesktopDevice {
|
|||||||
@override
|
@override
|
||||||
Future<void> buildForDevice(
|
Future<void> buildForDevice(
|
||||||
covariant MacOSApp package, {
|
covariant MacOSApp package, {
|
||||||
String mainPath,
|
required BuildInfo buildInfo,
|
||||||
BuildInfo buildInfo,
|
String? mainPath,
|
||||||
}) async {
|
}) async {
|
||||||
await buildMacOS(
|
await buildMacOS(
|
||||||
flutterProject: FlutterProject.current(),
|
flutterProject: FlutterProject.current(),
|
||||||
@ -82,7 +79,7 @@ class MacOSDevice extends DesktopDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String executablePathForDevice(covariant MacOSApp package, BuildMode buildMode) {
|
String? executablePathForDevice(covariant MacOSApp package, BuildMode buildMode) {
|
||||||
return package.executable(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
|
// 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
|
// no general-purpose way of knowing when a process is far enough along in
|
||||||
// the launch process for 'open' to foreground it.
|
// 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(<String>[
|
_processManager.run(<String>[
|
||||||
'open', package.applicationBundle(buildMode),
|
'open', applicationBundle,
|
||||||
]).then((ProcessResult result) {
|
]).then((ProcessResult result) {
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
_logger.printError('Failed to foreground app; open returned ${result.exitCode}');
|
_logger.printError('Failed to foreground app; open returned ${result.exitCode}');
|
||||||
@ -104,12 +106,12 @@ class MacOSDevice extends DesktopDevice {
|
|||||||
|
|
||||||
class MacOSDevices extends PollingDeviceDiscovery {
|
class MacOSDevices extends PollingDeviceDiscovery {
|
||||||
MacOSDevices({
|
MacOSDevices({
|
||||||
@required Platform platform,
|
required Platform platform,
|
||||||
@required MacOSWorkflow macOSWorkflow,
|
required MacOSWorkflow macOSWorkflow,
|
||||||
@required ProcessManager processManager,
|
required ProcessManager processManager,
|
||||||
@required Logger logger,
|
required Logger logger,
|
||||||
@required FileSystem fileSystem,
|
required FileSystem fileSystem,
|
||||||
@required OperatingSystemUtils operatingSystemUtils,
|
required OperatingSystemUtils operatingSystemUtils,
|
||||||
}) : _logger = logger,
|
}) : _logger = logger,
|
||||||
_platform = platform,
|
_platform = platform,
|
||||||
_macOSWorkflow = macOSWorkflow,
|
_macOSWorkflow = macOSWorkflow,
|
||||||
@ -132,7 +134,7 @@ class MacOSDevices extends PollingDeviceDiscovery {
|
|||||||
bool get canListAnything => _macOSWorkflow.canListDevices;
|
bool get canListAnything => _macOSWorkflow.canListDevices;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<Device>> pollingGetDevices({ Duration timeout }) async {
|
Future<List<Device>> pollingGetDevices({ Duration? timeout }) async {
|
||||||
if (!canListAnything) {
|
if (!canListAnything) {
|
||||||
return const <Device>[];
|
return const <Device>[];
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
// @dart = 2.8
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user