Add macOS to TargetPlatform (#43457)

This PR adds TargetPlatform.macOS to the TargetPlatform enum. This allows us to begin implementation of some adaptive UI based on which target platform is desired.

I haven't updated the tests here, that will come in a follow-up PR.
This commit is contained in:
Greg Spencer
2019-11-26 18:32:34 -08:00
committed by GitHub
parent e60c0f6852
commit 245d1b51ce
47 changed files with 174 additions and 64 deletions

View File

@@ -64,6 +64,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
case TargetPlatform.fuchsia:
return Icons.arrow_back;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return Icons.arrow_back_ios;
}
assert(false);

View File

@@ -360,6 +360,8 @@ class _PlatformItem extends StatelessWidget {
return 'Fuchsia';
case TargetPlatform.iOS:
return 'Cupertino';
case TargetPlatform.macOS:
return 'Material Desktop (macOS)';
}
assert(false);
return null;

View File

@@ -14,8 +14,12 @@ import 'gallery/app.dart';
// Sets a platform override for desktop to avoid exceptions. See
// https://flutter.dev/desktop#target-platform-override for more info.
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
// This is only included in the Gallery because Flutter's testing infrastructure
// uses the Gallery for various tests, and this allows us to test on desktop
// platforms that aren't yet supported in TargetPlatform.
void _enablePlatformOverrideForDesktop() {
if (!kIsWeb && (Platform.isMacOS || Platform.isWindows || Platform.isLinux)) {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
}