diff --git a/packages/flutter_tools/lib/src/base/os.dart b/packages/flutter_tools/lib/src/base/os.dart index 297bf10159c..1a12f4d69a0 100644 --- a/packages/flutter_tools/lib/src/base/os.dart +++ b/packages/flutter_tools/lib/src/base/os.dart @@ -618,13 +618,13 @@ enum HostPlatform { windows_arm64; String get platformName => switch (this) { - HostPlatform.darwin_x64 => 'x64', - HostPlatform.darwin_arm64 => 'arm64', - HostPlatform.linux_x64 => 'x64', - HostPlatform.linux_arm64 => 'arm64', - HostPlatform.linux_riscv64 => 'riscv64', - HostPlatform.windows_x64 => 'x64', - HostPlatform.windows_arm64 => 'arm64', + darwin_x64 => 'x64', + darwin_arm64 => 'arm64', + linux_x64 => 'x64', + linux_arm64 => 'arm64', + linux_riscv64 => 'riscv64', + windows_x64 => 'x64', + windows_arm64 => 'arm64', }; } diff --git a/packages/flutter_tools/lib/src/build_info.dart b/packages/flutter_tools/lib/src/build_info.dart index f2cf1321e58..e24464c4da9 100644 --- a/packages/flutter_tools/lib/src/build_info.dart +++ b/packages/flutter_tools/lib/src/build_info.dart @@ -644,79 +644,79 @@ enum TargetPlatform { String get fuchsiaArchForTargetPlatform { switch (this) { - case TargetPlatform.fuchsia_arm64: + case fuchsia_arm64: return 'arm64'; - case TargetPlatform.fuchsia_x64: + case fuchsia_x64: return 'x64'; - case TargetPlatform.android: - case TargetPlatform.android_arm: - case TargetPlatform.android_arm64: - case TargetPlatform.android_x64: - case TargetPlatform.darwin: - case TargetPlatform.ios: - case TargetPlatform.linux_arm64: - case TargetPlatform.linux_riscv64: - case TargetPlatform.linux_x64: - case TargetPlatform.tester: - case TargetPlatform.web_javascript: - case TargetPlatform.windows_x64: - case TargetPlatform.windows_arm64: - case TargetPlatform.unsupported: + case android: + case android_arm: + case android_arm64: + case android_x64: + case darwin: + case ios: + case linux_arm64: + case linux_riscv64: + case linux_x64: + case tester: + case web_javascript: + case windows_x64: + case windows_arm64: + case unsupported: throw UnsupportedError('Unexpected Fuchsia platform $this'); } } String get osName { switch (this) { - case TargetPlatform.linux_x64: - case TargetPlatform.linux_arm64: - case TargetPlatform.linux_riscv64: + case linux_x64: + case linux_arm64: + case linux_riscv64: return 'linux'; - case TargetPlatform.darwin: + case darwin: return 'macos'; - case TargetPlatform.windows_x64: - case TargetPlatform.windows_arm64: + case windows_x64: + case windows_arm64: return 'windows'; - case TargetPlatform.android: - case TargetPlatform.android_arm: - case TargetPlatform.android_arm64: - case TargetPlatform.android_x64: + case android: + case android_arm: + case android_arm64: + case android_x64: return 'android'; - case TargetPlatform.fuchsia_arm64: - case TargetPlatform.fuchsia_x64: + case fuchsia_arm64: + case fuchsia_x64: return 'fuchsia'; - case TargetPlatform.ios: + case ios: return 'ios'; - case TargetPlatform.tester: + case tester: return 'flutter-tester'; - case TargetPlatform.web_javascript: + case web_javascript: return 'web'; - case TargetPlatform.unsupported: + case unsupported: throw UnsupportedError('Unexpected target platform $this'); } } String get simpleName { switch (this) { - case TargetPlatform.linux_x64: - case TargetPlatform.darwin: - case TargetPlatform.windows_x64: + case linux_x64: + case darwin: + case windows_x64: return 'x64'; - case TargetPlatform.linux_arm64: - case TargetPlatform.windows_arm64: + case linux_arm64: + case windows_arm64: return 'arm64'; - case TargetPlatform.linux_riscv64: + case linux_riscv64: return 'riscv64'; - case TargetPlatform.android: - case TargetPlatform.android_arm: - case TargetPlatform.android_arm64: - case TargetPlatform.android_x64: - case TargetPlatform.fuchsia_arm64: - case TargetPlatform.fuchsia_x64: - case TargetPlatform.ios: - case TargetPlatform.tester: - case TargetPlatform.web_javascript: - case TargetPlatform.unsupported: + case android: + case android_arm: + case android_arm64: + case android_x64: + case fuchsia_arm64: + case fuchsia_x64: + case ios: + case tester: + case web_javascript: + case unsupported: throw UnsupportedError('Unexpected target platform $this'); } } @@ -741,9 +741,9 @@ enum DarwinArch { /// merged into a universal binary using the `lipo` tool. String get dartName { return switch (this) { - DarwinArch.armv7 => 'armv7', - DarwinArch.arm64 => 'arm64', - DarwinArch.x86_64 => 'x64', + armv7 => 'armv7', + arm64 => 'arm64', + x86_64 => 'x64', }; } } @@ -755,15 +755,15 @@ enum AndroidArch { x86_64; String get archName => switch (this) { - AndroidArch.armeabi_v7a => 'armeabi-v7a', - AndroidArch.arm64_v8a => 'arm64-v8a', - AndroidArch.x86_64 => 'x86_64', + armeabi_v7a => 'armeabi-v7a', + arm64_v8a => 'arm64-v8a', + x86_64 => 'x86_64', }; String get platformName => switch (this) { - AndroidArch.armeabi_v7a => 'android-arm', - AndroidArch.arm64_v8a => 'android-arm64', - AndroidArch.x86_64 => 'android-x64', + armeabi_v7a => 'android-arm', + arm64_v8a => 'android-arm64', + x86_64 => 'android-x64', }; } diff --git a/packages/flutter_tools/lib/src/darwin/darwin.dart b/packages/flutter_tools/lib/src/darwin/darwin.dart index 1c0cb8e6d0d..1a2da7ddbbc 100644 --- a/packages/flutter_tools/lib/src/darwin/darwin.dart +++ b/packages/flutter_tools/lib/src/darwin/darwin.dart @@ -71,12 +71,10 @@ enum FlutterDarwinPlatform { /// Minimum supported version for the platform. Version deploymentTarget() { - switch (this) { - case FlutterDarwinPlatform.ios: - return Version(13, 0, null); - case FlutterDarwinPlatform.macos: - return Version(10, 15, null); - } + return switch (this) { + ios => Version(13, 0, null), + macos => Version(10, 15, null), + }; } /// Artifact name for the platform and [mode]. @@ -117,11 +115,9 @@ enum FlutterDarwinPlatform { /// Returns corresponding [XcodeBasedProject] for the platform. XcodeBasedProject xcodeProject(FlutterProject project) { - switch (this) { - case FlutterDarwinPlatform.ios: - return project.ios; - case FlutterDarwinPlatform.macos: - return project.macos; - } + return switch (this) { + ios => project.ios, + macos => project.macos, + }; } } diff --git a/packages/flutter_tools/lib/src/drive/web_driver_service.dart b/packages/flutter_tools/lib/src/drive/web_driver_service.dart index 75e7e088431..ef736c51712 100644 --- a/packages/flutter_tools/lib/src/drive/web_driver_service.dart +++ b/packages/flutter_tools/lib/src/drive/web_driver_service.dart @@ -297,18 +297,18 @@ enum Browser implements CliEnum { @override String get helpText => switch (this) { - Browser.androidChrome => 'Chrome on Android (see also "--android-emulator").', - Browser.chrome => 'Google Chrome on this computer (see also "--chrome-binary").', - Browser.edge => 'Microsoft Edge on this computer (Windows only).', - Browser.firefox => 'Mozilla Firefox on this computer.', - Browser.iosSafari => 'Apple Safari on an iOS device.', - Browser.safari => 'Apple Safari on this computer (macOS only).', + androidChrome => 'Chrome on Android (see also "--android-emulator").', + chrome => 'Google Chrome on this computer (see also "--chrome-binary").', + edge => 'Microsoft Edge on this computer (Windows only).', + firefox => 'Mozilla Firefox on this computer.', + iosSafari => 'Apple Safari on an iOS device.', + safari => 'Apple Safari on this computer (macOS only).', }; @override String get cliName => kebabCase(name); - static Browser fromCliName(String? value) => Browser.values.singleWhere( + static Browser fromCliName(String? value) => values.singleWhere( (Browser element) => element.cliName == value, orElse: () => throw UnsupportedError('Browser $value not supported'), ); diff --git a/packages/flutter_tools/lib/src/web/file_generators/flutter_service_worker_js.dart b/packages/flutter_tools/lib/src/web/file_generators/flutter_service_worker_js.dart index 2769efbaed0..fe1d42cf739 100644 --- a/packages/flutter_tools/lib/src/web/file_generators/flutter_service_worker_js.dart +++ b/packages/flutter_tools/lib/src/web/file_generators/flutter_service_worker_js.dart @@ -26,12 +26,12 @@ enum ServiceWorkerStrategy implements CliEnum { @override String get helpText => switch (this) { - ServiceWorkerStrategy.offlineFirst => + offlineFirst => 'Attempt to cache the application shell eagerly and then lazily ' 'cache all subsequent assets as they are loaded. When making a ' 'network request for an asset, the offline cache will be ' 'preferred.', - ServiceWorkerStrategy.none => + none => 'Generate a service worker with no body. This is useful for local ' 'testing or in cases where the service worker caching ' 'functionality is not desirable',