diff --git a/dev/integration_tests/flutter_driver_screenshot_test/lib/main.dart b/dev/integration_tests/flutter_driver_screenshot_test/lib/main.dart index 175790812d..93a24a69bc 100644 --- a/dev/integration_tests/flutter_driver_screenshot_test/lib/main.dart +++ b/dev/integration_tests/flutter_driver_screenshot_test/lib/main.dart @@ -83,10 +83,14 @@ class _MyHomePageState extends State<_MyHomePage> { return (await deviceInfo.androidInfo).model; case TargetPlatform.fuchsia: return 'fuchsia'; - default: + case TargetPlatform.macOS: + case TargetPlatform.linux: + case TargetPlatform.windows: return 'unsupported'; + break; } - break; + assert(false, 'Unhandled Theme target platform ${Theme.of(context).platform}.'); + return 'unsupported'; } return 'unknown message: "$message"'; } diff --git a/dev/manual_tests/lib/actions.dart b/dev/manual_tests/lib/actions.dart index 02839ffee5..8eb50fdb01 100644 --- a/dev/manual_tests/lib/actions.dart +++ b/dev/manual_tests/lib/actions.dart @@ -2,24 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(const MaterialApp( title: 'Actions Demo', home: FocusDemo(), diff --git a/dev/manual_tests/lib/animated_icons.dart b/dev/manual_tests/lib/animated_icons.dart index 2b3587443b..767c4be426 100644 --- a/dev/manual_tests/lib/animated_icons.dart +++ b/dev/manual_tests/lib/animated_icons.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. -import 'dart:io'; - -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class AnimatedIconsTestApp extends StatelessWidget { @@ -108,16 +105,4 @@ class IconSample { final String description; } -// 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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - -void main() { - _enablePlatformOverrideForDesktop(); - runApp(AnimatedIconsTestApp()); -} +void main() => runApp(AnimatedIconsTestApp()); diff --git a/dev/manual_tests/lib/density.dart b/dev/manual_tests/lib/density.dart index 710d3e7806..ea4c0209ab 100644 --- a/dev/manual_tests/lib/density.dart +++ b/dev/manual_tests/lib/density.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/scheduler.dart' show timeDilation; @@ -24,19 +23,7 @@ final Map m2SwatchColors = { }; final MaterialColor m2Swatch = MaterialColor(m2SwatchColors[500].value, m2SwatchColors); -// 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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - -void main() { - _enablePlatformOverrideForDesktop(); - runApp(MyApp()); -} +void main() => runApp(MyApp()); class MyApp extends StatelessWidget { static const String _title = 'Density Test'; diff --git a/dev/manual_tests/lib/drag_and_drop.dart b/dev/manual_tests/lib/drag_and_drop.dart index cf0cdf0660..7b4b0cfa28 100644 --- a/dev/manual_tests/lib/drag_and_drop.dart +++ b/dev/manual_tests/lib/drag_and_drop.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; import 'dart:math' as math; import 'package:flutter/foundation.dart'; @@ -296,17 +295,7 @@ class DragAndDropAppState extends State { } } -// 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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(MaterialApp( title: 'Drag and Drop Flutter Demo', home: DragAndDropApp(), diff --git a/dev/manual_tests/lib/focus.dart b/dev/manual_tests/lib/focus.dart index 00e5c2db9c..04712c2f6c 100644 --- a/dev/manual_tests/lib/focus.dart +++ b/dev/manual_tests/lib/focus.dart @@ -2,24 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(const MaterialApp( title: 'Focus Demo', home: FocusDemo(), diff --git a/dev/manual_tests/lib/hover.dart b/dev/manual_tests/lib/hover.dart index a63158060b..ee80315ca4 100644 --- a/dev/manual_tests/lib/hover.dart +++ b/dev/manual_tests/lib/hover.dart @@ -2,23 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(const MaterialApp( title: 'Hover Demo', home: HoverDemo(), diff --git a/dev/manual_tests/lib/main.dart b/dev/manual_tests/lib/main.dart index 42439ea5c8..347520d971 100644 --- a/dev/manual_tests/lib/main.dart +++ b/dev/manual_tests/lib/main.dart @@ -2,22 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - -import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(const Directionality( textDirection: TextDirection.ltr, child: Center( diff --git a/dev/manual_tests/lib/material_arc.dart b/dev/manual_tests/lib/material_arc.dart index 7d2c83915a..fd00410069 100644 --- a/dev/manual_tests/lib/material_arc.dart +++ b/dev/manual_tests/lib/material_arc.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; @@ -475,17 +474,7 @@ class _AnimationDemoState extends State with TickerProviderStateM } } -// 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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(const MaterialApp( home: AnimationDemo(), )); diff --git a/dev/manual_tests/lib/overlay_geometry.dart b/dev/manual_tests/lib/overlay_geometry.dart index a223fa44e7..21641812eb 100644 --- a/dev/manual_tests/lib/overlay_geometry.dart +++ b/dev/manual_tests/lib/overlay_geometry.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. -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; @@ -206,17 +204,7 @@ class OverlayGeometryAppState extends State { } } -// 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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(MaterialApp( theme: ThemeData( brightness: Brightness.light, diff --git a/dev/manual_tests/lib/page_view.dart b/dev/manual_tests/lib/page_view.dart index 94e4187639..5ff1d92a11 100644 --- a/dev/manual_tests/lib/page_view.dart +++ b/dev/manual_tests/lib/page_view.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. -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -141,17 +139,7 @@ class PageViewAppState extends State { } } -// 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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(MaterialApp( title: 'PageView', theme: ThemeData( diff --git a/dev/manual_tests/lib/raw_keyboard.dart b/dev/manual_tests/lib/raw_keyboard.dart index d794451099..c329d6029f 100644 --- a/dev/manual_tests/lib/raw_keyboard.dart +++ b/dev/manual_tests/lib/raw_keyboard.dart @@ -2,23 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(MaterialApp( title: 'Hardware Key Demo', home: Scaffold( diff --git a/dev/manual_tests/lib/text.dart b/dev/manual_tests/lib/text.dart index 3ca82aca28..9835316600 100644 --- a/dev/manual_tests/lib/text.dart +++ b/dev/manual_tests/lib/text.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; import 'dart:math' as math; import 'package:flutter/foundation.dart'; @@ -12,17 +11,7 @@ import 'package:flutter/scheduler.dart'; int seed = 0; -// 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. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} - void main() { - _enablePlatformOverrideForDesktop(); runApp(MaterialApp( title: 'Text tester', home: const Home(), diff --git a/examples/flutter_gallery/lib/demo/material/drawer_demo.dart b/examples/flutter_gallery/lib/demo/material/drawer_demo.dart index c082cb8c3e..edfac39115 100644 --- a/examples/flutter_gallery/lib/demo/material/drawer_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/drawer_demo.dart @@ -62,6 +62,8 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { switch (Theme.of(context).platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return Icons.arrow_back; case TargetPlatform.iOS: case TargetPlatform.macOS: diff --git a/examples/flutter_gallery/lib/gallery/options.dart b/examples/flutter_gallery/lib/gallery/options.dart index 0bb47657a3..2f7337cb36 100644 --- a/examples/flutter_gallery/lib/gallery/options.dart +++ b/examples/flutter_gallery/lib/gallery/options.dart @@ -413,8 +413,12 @@ class _PlatformItem extends StatelessWidget { return 'Fuchsia'; case TargetPlatform.iOS: return 'Cupertino'; + case TargetPlatform.linux: + return 'Material Desktop (linux)'; case TargetPlatform.macOS: return 'Material Desktop (macOS)'; + case TargetPlatform.windows: + return 'Material Desktop (Windows)'; } assert(false); return null; diff --git a/packages/flutter/lib/src/cupertino/picker.dart b/packages/flutter/lib/src/cupertino/picker.dart index 65b3f53c84..e379e7e9b6 100644 --- a/packages/flutter/lib/src/cupertino/picker.dart +++ b/packages/flutter/lib/src/cupertino/picker.dart @@ -234,7 +234,9 @@ class _CupertinoPickerState extends State { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: case TargetPlatform.macOS: + case TargetPlatform.windows: hasSuitableHapticHardware = false; break; } diff --git a/packages/flutter/lib/src/cupertino/switch.dart b/packages/flutter/lib/src/cupertino/switch.dart index ff3982e196..3d39e076b8 100644 --- a/packages/flutter/lib/src/cupertino/switch.dart +++ b/packages/flutter/lib/src/cupertino/switch.dart @@ -456,7 +456,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: case TargetPlatform.macOS: + case TargetPlatform.windows: break; } } diff --git a/packages/flutter/lib/src/foundation/_platform_io.dart b/packages/flutter/lib/src/foundation/_platform_io.dart index cd3df97303..a8e000523b 100644 --- a/packages/flutter/lib/src/foundation/_platform_io.dart +++ b/packages/flutter/lib/src/foundation/_platform_io.dart @@ -9,14 +9,18 @@ import 'platform.dart' as platform; /// The dart:io implementation of [platform.defaultTargetPlatform]. platform.TargetPlatform get defaultTargetPlatform { platform.TargetPlatform result; - if (Platform.isIOS) { - result = platform.TargetPlatform.iOS; - } else if (Platform.isMacOS) { - result = platform.TargetPlatform.macOS; - } else if (Platform.isAndroid) { + if (Platform.isAndroid) { result = platform.TargetPlatform.android; + } else if (Platform.isIOS) { + result = platform.TargetPlatform.iOS; } else if (Platform.isFuchsia) { result = platform.TargetPlatform.fuchsia; + } else if (Platform.isLinux) { + result = platform.TargetPlatform.linux; + } else if (Platform.isMacOS) { + result = platform.TargetPlatform.macOS; + } else if (Platform.isWindows) { + result = platform.TargetPlatform.windows; } assert(() { if (Platform.environment.containsKey('FLUTTER_TEST')) diff --git a/packages/flutter/lib/src/foundation/binding.dart b/packages/flutter/lib/src/foundation/binding.dart index bf2776fd16..957f85906f 100644 --- a/packages/flutter/lib/src/foundation/binding.dart +++ b/packages/flutter/lib/src/foundation/binding.dart @@ -161,14 +161,20 @@ abstract class BindingBase { case 'android': debugDefaultTargetPlatformOverride = TargetPlatform.android; break; + case 'fuchsia': + debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; + break; case 'iOS': debugDefaultTargetPlatformOverride = TargetPlatform.iOS; break; + case 'linux': + debugDefaultTargetPlatformOverride = TargetPlatform.linux; + break; case 'macOS': debugDefaultTargetPlatformOverride = TargetPlatform.macOS; break; - case 'fuchsia': - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; + case 'windows': + debugDefaultTargetPlatformOverride = TargetPlatform.windows; break; case 'default': default: diff --git a/packages/flutter/lib/src/foundation/platform.dart b/packages/flutter/lib/src/foundation/platform.dart index 8ce65f4b4b..4de7a57b8b 100644 --- a/packages/flutter/lib/src/foundation/platform.dart +++ b/packages/flutter/lib/src/foundation/platform.dart @@ -45,11 +45,17 @@ enum TargetPlatform { /// Fuchsia: fuchsia, - /// iOS: + /// iOS: iOS, - /// macOS: + /// Linux: + linux, + + /// macOS: macOS, + + /// Windows: + windows, } /// Override the [defaultTargetPlatform]. diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index 80922ba404..be3789b13b 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -548,7 +548,9 @@ class _MaterialScrollBehavior extends ScrollBehavior { // the base class as well. switch (getPlatform(context)) { case TargetPlatform.iOS: + case TargetPlatform.linux: case TargetPlatform.macOS: + case TargetPlatform.windows: return child; case TargetPlatform.android: case TargetPlatform.fuchsia: diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index a8a37c5dcf..30ea7fe4c8 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -426,6 +426,8 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { switch (theme.platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return false; case TargetPlatform.iOS: case TargetPlatform.macOS: @@ -516,6 +518,8 @@ class _AppBarState extends State { switch (theme.platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: namesRoute = true; break; case TargetPlatform.iOS: diff --git a/packages/flutter/lib/src/material/back_button.dart b/packages/flutter/lib/src/material/back_button.dart index 4666ac814e..54922081ed 100644 --- a/packages/flutter/lib/src/material/back_button.dart +++ b/packages/flutter/lib/src/material/back_button.dart @@ -32,6 +32,8 @@ class BackButtonIcon extends StatelessWidget { switch (platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return Icons.arrow_back; case TargetPlatform.iOS: case TargetPlatform.macOS: diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 5159a591f8..4a72bf936b 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -339,6 +339,8 @@ class _ModalBottomSheetState extends State<_ModalBottomSheet> { return ''; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return localizations.dialogLabel; } return null; diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 22e81baa8e..19f8f586e4 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -908,6 +908,8 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { switch (Theme.of(context).platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: HapticFeedback.vibrate(); break; case TargetPlatform.iOS: diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index 340a1d6561..be0f638321 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -464,6 +464,8 @@ class AlertDialog extends StatelessWidget { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: label = semanticLabel ?? MaterialLocalizations.of(context)?.alertDialogLabel; } } @@ -794,6 +796,8 @@ class SimpleDialog extends StatelessWidget { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: label = semanticLabel ?? MaterialLocalizations.of(context)?.dialogLabel; } } diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index b23d649210..b626d65985 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -182,6 +182,8 @@ class Drawer extends StatelessWidget { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: label = semanticLabel ?? MaterialLocalizations.of(context)?.drawerLabel; } return Semantics( @@ -536,6 +538,8 @@ class DrawerControllerState extends State with SingleTickerPro case TargetPlatform.iOS: case TargetPlatform.macOS: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: platformHasBackButton = false; break; } diff --git a/packages/flutter/lib/src/material/feedback.dart b/packages/flutter/lib/src/material/feedback.dart index 61f74e9766..b0a04be231 100644 --- a/packages/flutter/lib/src/material/feedback.dart +++ b/packages/flutter/lib/src/material/feedback.dart @@ -99,9 +99,15 @@ class Feedback { case TargetPlatform.android: case TargetPlatform.fuchsia: return SystemSound.play(SystemSoundType.click); - default: + case TargetPlatform.iOS: + case TargetPlatform.linux: + case TargetPlatform.macOS: + case TargetPlatform.windows: return Future.value(); + break; } + assert(false, 'Unhandled TargetPlatform ${_platform(context)}'); + return Future.value(); } /// Wraps a [GestureTapCallback] to provide platform specific feedback for a @@ -138,9 +144,15 @@ class Feedback { case TargetPlatform.android: case TargetPlatform.fuchsia: return HapticFeedback.vibrate(); - default: + case TargetPlatform.iOS: + case TargetPlatform.linux: + case TargetPlatform.macOS: + case TargetPlatform.windows: return Future.value(); + break; } + assert(false, 'Unhandled TargetPlatform ${_platform(context)}'); + return Future.value(); } /// Wraps a [GestureLongPressCallback] to provide platform specific feedback diff --git a/packages/flutter/lib/src/material/flexible_space_bar.dart b/packages/flutter/lib/src/material/flexible_space_bar.dart index 46a217026f..cd79d8c396 100644 --- a/packages/flutter/lib/src/material/flexible_space_bar.dart +++ b/packages/flutter/lib/src/material/flexible_space_bar.dart @@ -237,6 +237,8 @@ class _FlexibleSpaceBarState extends State { switch (theme.platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return false; case TargetPlatform.iOS: case TargetPlatform.macOS: @@ -345,8 +347,10 @@ class _FlexibleSpaceBarState extends State { case TargetPlatform.macOS: title = widget.title; break; - case TargetPlatform.fuchsia: case TargetPlatform.android: + case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: title = Semantics( namesRoute: true, child: widget.title, diff --git a/packages/flutter/lib/src/material/page_transitions_theme.dart b/packages/flutter/lib/src/material/page_transitions_theme.dart index e5a05667b9..145005ce71 100644 --- a/packages/flutter/lib/src/material/page_transitions_theme.dart +++ b/packages/flutter/lib/src/material/page_transitions_theme.dart @@ -494,7 +494,9 @@ class PageTransitionsTheme extends Diagnosticable { static const Map _defaultBuilders = { TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), + TargetPlatform.linux: FadeUpwardsPageTransitionsBuilder(), TargetPlatform.macOS: CupertinoPageTransitionsBuilder(), + TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(), }; /// The [PageTransitionsBuilder]s supported by this theme. diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 0255a54e55..d29b99a0ab 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -837,6 +837,8 @@ Future showMenu({ break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: label = semanticLabel ?? MaterialLocalizations.of(context)?.popupMenuLabel; } @@ -1096,6 +1098,8 @@ class PopupMenuButtonState extends State> { switch (platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return const Icon(Icons.more_vert); case TargetPlatform.iOS: case TargetPlatform.macOS: diff --git a/packages/flutter/lib/src/material/range_slider.dart b/packages/flutter/lib/src/material/range_slider.dart index 9f575eec91..d33b4e52ff 100644 --- a/packages/flutter/lib/src/material/range_slider.dart +++ b/packages/flutter/lib/src/material/range_slider.dart @@ -903,10 +903,14 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix return 0.1; case TargetPlatform.android: case TargetPlatform.fuchsia: - default: + case TargetPlatform.linux: + case TargetPlatform.macOS: + case TargetPlatform.windows: // Matches Android implementation of material slider. return 0.05; } + assert(false, 'Unhandled TargetPlatform $_platform'); + return 0.05; } void _updateLabelPainters() { diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index 732b07f8d6..17c061bc54 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -2498,6 +2498,8 @@ class ScaffoldState extends State with TickerProviderStateMixin { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: break; } diff --git a/packages/flutter/lib/src/material/scrollbar.dart b/packages/flutter/lib/src/material/scrollbar.dart index 3426ea19dd..e77c5172b0 100644 --- a/packages/flutter/lib/src/material/scrollbar.dart +++ b/packages/flutter/lib/src/material/scrollbar.dart @@ -96,6 +96,8 @@ class _ScrollbarState extends State with TickerProviderStateMixin { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: _themeColor = theme.highlightColor.withOpacity(1.0); _textDirection = Directionality.of(context); _materialPainter = _buildMaterialScrollbarPainter(); diff --git a/packages/flutter/lib/src/material/search.dart b/packages/flutter/lib/src/material/search.dart index c124e2bb89..1660e89f90 100644 --- a/packages/flutter/lib/src/material/search.dart +++ b/packages/flutter/lib/src/material/search.dart @@ -492,6 +492,8 @@ class _SearchPageState extends State<_SearchPage> { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: routeName = searchFieldLabel; } diff --git a/packages/flutter/lib/src/material/selectable_text.dart b/packages/flutter/lib/src/material/selectable_text.dart index 253529550c..455c2dd337 100644 --- a/packages/flutter/lib/src/material/selectable_text.dart +++ b/packages/flutter/lib/src/material/selectable_text.dart @@ -78,6 +78,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: renderEditable.selectWordsInRange( from: details.globalPosition - details.offsetFromOrigin, to: details.globalPosition, @@ -99,6 +101,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: renderEditable.selectPosition(cause: SelectionChangedCause.tap); break; } @@ -120,6 +124,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: renderEditable.selectWord(cause: SelectionChangedCause.longPress); Feedback.forLongPress(_state.context); break; @@ -494,6 +500,8 @@ class _SelectableTextState extends State with AutomaticKeepAlive return; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: // Do nothing. } } @@ -567,6 +575,8 @@ class _SelectableTextState extends State with AutomaticKeepAlive case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: forcePressEnabled = false; textSelectionControls = materialTextSelectionControls; paintCursorAboveText = false; diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 77ce0e5edb..6a473b10f2 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -502,6 +502,8 @@ class _SliderState extends State with TickerProviderStateMixin { switch (theme.platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return _buildMaterialSlider(context); case TargetPlatform.iOS: case TargetPlatform.macOS: @@ -892,13 +894,16 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { switch (_platform) { case TargetPlatform.iOS: case TargetPlatform.macOS: - // Matches iOS implementation of material slider. + // Matches iOS implementation of material slider. return 0.1; case TargetPlatform.android: case TargetPlatform.fuchsia: - // Matches Android implementation of material slider. + case TargetPlatform.linux: + case TargetPlatform.windows: + // Matches Android implementation of material slider. return 0.05; } + assert(false, 'Unhandled TargetPlatform $_platform'); return 0.0; } diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index c4b05ae1b6..ad229ec0e9 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -352,6 +352,8 @@ class _SwitchState extends State with TickerProviderStateMixin { switch (theme.platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return buildMaterialSwitch(context); case TargetPlatform.iOS: case TargetPlatform.macOS: diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 87b50cd73b..865097b05f 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -69,6 +69,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: renderEditable.selectWordsInRange( from: details.globalPosition - details.offsetFromOrigin, to: details.globalPosition, @@ -90,6 +92,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: renderEditable.selectPosition(cause: SelectionChangedCause.tap); break; } @@ -112,6 +116,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: renderEditable.selectWord(cause: SelectionChangedCause.longPress); Feedback.forLongPress(_state.context); break; @@ -919,6 +925,8 @@ class _TextFieldState extends State implements TextSelectionGestureDe return; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: // Do nothing. } } @@ -980,6 +988,8 @@ class _TextFieldState extends State implements TextSelectionGestureDe case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: forcePressEnabled = false; textSelectionControls = materialTextSelectionControls; paintCursorAboveText = false; diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index 42e36a5cea..066a1431c8 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -206,6 +206,8 @@ class _DayPeriodControl extends StatelessWidget { switch (fragmentContext.targetPlatform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: _announceToAccessibility(context, MaterialLocalizations.of(context).anteMeridiemAbbreviation); break; case TargetPlatform.iOS: @@ -222,6 +224,8 @@ class _DayPeriodControl extends StatelessWidget { switch (fragmentContext.targetPlatform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: _announceToAccessibility(context, MaterialLocalizations.of(context).postMeridiemAbbreviation); break; case TargetPlatform.iOS: @@ -1535,6 +1539,8 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { switch (Theme.of(context).platform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: _vibrateTimer?.cancel(); _vibrateTimer = Timer(_kVibrateCommitDelay, () { HapticFeedback.vibrate(); diff --git a/packages/flutter/lib/src/material/typography.dart b/packages/flutter/lib/src/material/typography.dart index 4eb0f48ccc..a1b23463d6 100644 --- a/packages/flutter/lib/src/material/typography.dart +++ b/packages/flutter/lib/src/material/typography.dart @@ -182,6 +182,15 @@ class Typography extends Diagnosticable { case TargetPlatform.fuchsia: black ??= blackMountainView; white ??= whiteMountainView; + break; + case TargetPlatform.windows: + black ??= blackRedmond; + white ??= whiteRedmond; + break; + case TargetPlatform.linux: + black ??= blackHelsinki; + white ??= whiteHelsinki; + break; } return Typography._(black, white, englishLike, dense, tall); } @@ -366,6 +375,85 @@ class Typography extends Diagnosticable { overline : TextStyle(debugLabel: 'whiteMountainView overline', fontFamily: 'Roboto', inherit: true, color: Colors.white, decoration: TextDecoration.none), ); + /// A material design text theme with dark glyphs based on Segoe UI. + /// + /// This [TextTheme] provides color but not geometry (font size, weight, etc). + static const TextTheme blackRedmond = TextTheme( + headline1 : TextStyle(debugLabel: 'blackRedmond headline1', fontFamily: 'Segoe UI', inherit: true, color: Colors.black54, decoration: TextDecoration.none), + headline2 : TextStyle(debugLabel: 'blackRedmond headline2', fontFamily: 'Segoe UI', inherit: true, color: Colors.black54, decoration: TextDecoration.none), + headline3 : TextStyle(debugLabel: 'blackRedmond headline3', fontFamily: 'Segoe UI', inherit: true, color: Colors.black54, decoration: TextDecoration.none), + headline4 : TextStyle(debugLabel: 'blackRedmond headline4', fontFamily: 'Segoe UI', inherit: true, color: Colors.black54, decoration: TextDecoration.none), + headline5 : TextStyle(debugLabel: 'blackRedmond headline5', fontFamily: 'Segoe UI', inherit: true, color: Colors.black87, decoration: TextDecoration.none), + headline6 : TextStyle(debugLabel: 'blackRedmond headline6', fontFamily: 'Segoe UI', inherit: true, color: Colors.black87, decoration: TextDecoration.none), + bodyText1 : TextStyle(debugLabel: 'blackRedmond bodyText1', fontFamily: 'Segoe UI', inherit: true, color: Colors.black87, decoration: TextDecoration.none), + bodyText2 : TextStyle(debugLabel: 'blackRedmond bodyText2', fontFamily: 'Segoe UI', inherit: true, color: Colors.black87, decoration: TextDecoration.none), + subtitle1 : TextStyle(debugLabel: 'blackRedmond subtitle1', fontFamily: 'Segoe UI', inherit: true, color: Colors.black87, decoration: TextDecoration.none), + subtitle2 : TextStyle(debugLabel: 'blackRedmond subtitle2', fontFamily: 'Segoe UI', inherit: true, color: Colors.black, decoration: TextDecoration.none), + caption : TextStyle(debugLabel: 'blackRedmond caption', fontFamily: 'Segoe UI', inherit: true, color: Colors.black54, decoration: TextDecoration.none), + button : TextStyle(debugLabel: 'blackRedmond button', fontFamily: 'Segoe UI', inherit: true, color: Colors.black87, decoration: TextDecoration.none), + overline : TextStyle(debugLabel: 'blackRedmond overline', fontFamily: 'Segoe UI', inherit: true, color: Colors.black, decoration: TextDecoration.none), + ); + + /// A material design text theme with light glyphs based on Segoe UI. + /// + /// This [TextTheme] provides color but not geometry (font size, weight, etc). + static const TextTheme whiteRedmond = TextTheme( + headline1 : TextStyle(debugLabel: 'whiteRedmond headline1', fontFamily: 'Segoe UI', inherit: true, color: Colors.white70, decoration: TextDecoration.none), + headline2 : TextStyle(debugLabel: 'whiteRedmond headline2', fontFamily: 'Segoe UI', inherit: true, color: Colors.white70, decoration: TextDecoration.none), + headline3 : TextStyle(debugLabel: 'whiteRedmond headline3', fontFamily: 'Segoe UI', inherit: true, color: Colors.white70, decoration: TextDecoration.none), + headline4 : TextStyle(debugLabel: 'whiteRedmond headline4', fontFamily: 'Segoe UI', inherit: true, color: Colors.white70, decoration: TextDecoration.none), + headline5 : TextStyle(debugLabel: 'whiteRedmond headline5', fontFamily: 'Segoe UI', inherit: true, color: Colors.white, decoration: TextDecoration.none), + headline6 : TextStyle(debugLabel: 'whiteRedmond headline6', fontFamily: 'Segoe UI', inherit: true, color: Colors.white, decoration: TextDecoration.none), + bodyText1 : TextStyle(debugLabel: 'whiteRedmond bodyText1', fontFamily: 'Segoe UI', inherit: true, color: Colors.white, decoration: TextDecoration.none), + bodyText2 : TextStyle(debugLabel: 'whiteRedmond bodyText2', fontFamily: 'Segoe UI', inherit: true, color: Colors.white, decoration: TextDecoration.none), + subtitle1 : TextStyle(debugLabel: 'whiteRedmond subtitle1', fontFamily: 'Segoe UI', inherit: true, color: Colors.white, decoration: TextDecoration.none), + subtitle2 : TextStyle(debugLabel: 'whiteRedmond subtitle2', fontFamily: 'Segoe UI', inherit: true, color: Colors.white, decoration: TextDecoration.none), + caption : TextStyle(debugLabel: 'whiteRedmond caption', fontFamily: 'Segoe UI', inherit: true, color: Colors.white70, decoration: TextDecoration.none), + button : TextStyle(debugLabel: 'whiteRedmond button', fontFamily: 'Segoe UI', inherit: true, color: Colors.white, decoration: TextDecoration.none), + overline : TextStyle(debugLabel: 'whiteRedmond overline', fontFamily: 'Segoe UI', inherit: true, color: Colors.white, decoration: TextDecoration.none), + ); + + static const List _helsinkiFontFallbacks = ['Ubuntu', 'Cantarell', 'DejaVu Sans', 'Liberation Sans', 'Arial']; + /// A material design text theme with dark glyphs based on Roboto, with + /// fallback fonts that are likely (but not guaranteed) to be installed on + /// Linux. + /// + /// This [TextTheme] provides color but not geometry (font size, weight, etc). + static const TextTheme blackHelsinki = TextTheme( + headline1 : TextStyle(debugLabel: 'blackHelsinki headline1', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black54, decoration: TextDecoration.none), + headline2 : TextStyle(debugLabel: 'blackHelsinki headline2', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black54, decoration: TextDecoration.none), + headline3 : TextStyle(debugLabel: 'blackHelsinki headline3', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black54, decoration: TextDecoration.none), + headline4 : TextStyle(debugLabel: 'blackHelsinki headline4', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black54, decoration: TextDecoration.none), + headline5 : TextStyle(debugLabel: 'blackHelsinki headline5', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black87, decoration: TextDecoration.none), + headline6 : TextStyle(debugLabel: 'blackHelsinki headline6', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black87, decoration: TextDecoration.none), + bodyText1 : TextStyle(debugLabel: 'blackHelsinki bodyText1', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black87, decoration: TextDecoration.none), + bodyText2 : TextStyle(debugLabel: 'blackHelsinki bodyText2', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black87, decoration: TextDecoration.none), + subtitle1 : TextStyle(debugLabel: 'blackHelsinki subtitle1', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black87, decoration: TextDecoration.none), + subtitle2 : TextStyle(debugLabel: 'blackHelsinki subtitle2', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black, decoration: TextDecoration.none), + caption : TextStyle(debugLabel: 'blackHelsinki caption', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black54, decoration: TextDecoration.none), + button : TextStyle(debugLabel: 'blackHelsinki button', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black87, decoration: TextDecoration.none), + overline : TextStyle(debugLabel: 'blackHelsinki overline', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.black, decoration: TextDecoration.none), + ); + + /// A material design text theme with light glyphs based on Roboto, with fallbacks of DejaVu Sans, Liberation Sans and Arial. + /// + /// This [TextTheme] provides color but not geometry (font size, weight, etc). + static const TextTheme whiteHelsinki = TextTheme( + headline1 : TextStyle(debugLabel: 'whiteHelsinki headline1', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white70, decoration: TextDecoration.none), + headline2 : TextStyle(debugLabel: 'whiteHelsinki headline2', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white70, decoration: TextDecoration.none), + headline3 : TextStyle(debugLabel: 'whiteHelsinki headline3', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white70, decoration: TextDecoration.none), + headline4 : TextStyle(debugLabel: 'whiteHelsinki headline4', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white70, decoration: TextDecoration.none), + headline5 : TextStyle(debugLabel: 'whiteHelsinki headline5', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white, decoration: TextDecoration.none), + headline6 : TextStyle(debugLabel: 'whiteHelsinki headline6', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white, decoration: TextDecoration.none), + bodyText1 : TextStyle(debugLabel: 'whiteHelsinki bodyText1', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white, decoration: TextDecoration.none), + bodyText2 : TextStyle(debugLabel: 'whiteHelsinki bodyText2', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white, decoration: TextDecoration.none), + subtitle1 : TextStyle(debugLabel: 'whiteHelsinki subtitle1', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white, decoration: TextDecoration.none), + subtitle2 : TextStyle(debugLabel: 'whiteHelsinki subtitle2', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white, decoration: TextDecoration.none), + caption : TextStyle(debugLabel: 'whiteHelsinki caption', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white70, decoration: TextDecoration.none), + button : TextStyle(debugLabel: 'whiteHelsinki button', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white, decoration: TextDecoration.none), + overline : TextStyle(debugLabel: 'whiteHelsinki overline', fontFamily: 'Roboto', fontFamilyFallback: _helsinkiFontFallbacks, inherit: true, color: Colors.white, decoration: TextDecoration.none), + ); + /// A material design text theme with dark glyphs based on San Francisco. /// /// This [TextTheme] provides color but not geometry (font size, weight, etc). diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index 190886eefd..fa62b49073 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -1732,6 +1732,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { return Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight + 2); case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return Rect.fromLTWH(0.0, _kCaretHeightOffset, cursorWidth, preferredLineHeight - 2.0 * _kCaretHeightOffset); } return null; @@ -1800,6 +1802,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { break; case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: // Override the height to take the full height of the glyph at the TextPosition // when not on iOS. iOS has special handling that creates a taller caret. // TODO(garyq): See the TODO for _getCaretPrototype. diff --git a/packages/flutter/lib/src/rendering/view.dart b/packages/flutter/lib/src/rendering/view.dart index bd38fe5c61..b67795e1a7 100644 --- a/packages/flutter/lib/src/rendering/view.dart +++ b/packages/flutter/lib/src/rendering/view.dart @@ -255,7 +255,9 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin break; case TargetPlatform.fuchsia: case TargetPlatform.iOS: + case TargetPlatform.linux: case TargetPlatform.macOS: + case TargetPlatform.windows: break; } // If there are no overlay styles in the UI don't bother updating. diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 9e544cf185..fae8ea0363 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -919,6 +919,8 @@ class WidgetsApp extends StatefulWidget { switch (defaultTargetPlatform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return _defaultShortcuts; case TargetPlatform.macOS: return _defaultMacOsShortcuts; diff --git a/packages/flutter/lib/src/widgets/modal_barrier.dart b/packages/flutter/lib/src/widgets/modal_barrier.dart index 1a1ea57b8f..24e00029af 100644 --- a/packages/flutter/lib/src/widgets/modal_barrier.dart +++ b/packages/flutter/lib/src/widgets/modal_barrier.dart @@ -79,6 +79,8 @@ class ModalBarrier extends StatelessWidget { switch (defaultTargetPlatform) { case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: platformSupportsDismissingBarrier = false; break; case TargetPlatform.iOS: diff --git a/packages/flutter/lib/src/widgets/scroll_configuration.dart b/packages/flutter/lib/src/widgets/scroll_configuration.dart index f295b18a59..86b16cd280 100644 --- a/packages/flutter/lib/src/widgets/scroll_configuration.dart +++ b/packages/flutter/lib/src/widgets/scroll_configuration.dart @@ -35,7 +35,9 @@ class ScrollBehavior { // _MaterialScrollBehavior as well. switch (getPlatform(context)) { case TargetPlatform.iOS: + case TargetPlatform.linux: case TargetPlatform.macOS: + case TargetPlatform.windows: return child; case TargetPlatform.android: case TargetPlatform.fuchsia: @@ -59,6 +61,8 @@ class ScrollBehavior { return const BouncingScrollPhysics(); case TargetPlatform.android: case TargetPlatform.fuchsia: + case TargetPlatform.linux: + case TargetPlatform.windows: return const ClampingScrollPhysics(); } return null; diff --git a/packages/flutter/test/foundation/service_extensions_test.dart b/packages/flutter/test/foundation/service_extensions_test.dart index f8a598b211..e0221ea3b8 100644 --- a/packages/flutter/test/foundation/service_extensions_test.dart +++ b/packages/flutter/test/foundation/service_extensions_test.dart @@ -530,11 +530,27 @@ void main() { extensionChangedEvent = extensionChangedEvents.last; expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['value'], 'iOS'); + result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'linux'})); + expect(result, {'value': 'linux'}); + expect(binding.reassembled, 7); + expect(defaultTargetPlatform, TargetPlatform.linux); + expect(extensionChangedEvents.length, 7); + extensionChangedEvent = extensionChangedEvents.last; + expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); + expect(extensionChangedEvent['value'], 'linux'); + result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'windows'})); + expect(result, {'value': 'windows'}); + expect(binding.reassembled, 8); + expect(defaultTargetPlatform, TargetPlatform.windows); + expect(extensionChangedEvents.length, 8); + extensionChangedEvent = extensionChangedEvents.last; + expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); + expect(extensionChangedEvent['value'], 'windows'); result = await hasReassemble(binding.testExtension('platformOverride', {'value': 'bogus'})); expect(result, {'value': 'android'}); - expect(binding.reassembled, 7); + expect(binding.reassembled, 9); expect(defaultTargetPlatform, TargetPlatform.android); - expect(extensionChangedEvents.length, 7); + expect(extensionChangedEvents.length, 9); extensionChangedEvent = extensionChangedEvents.last; expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['value'], 'android'); diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart index aeb8577503..042e2cfb63 100644 --- a/packages/flutter/test/material/back_button_test.dart +++ b/packages/flutter/test/material/back_button_test.dart @@ -68,7 +68,9 @@ void main() { testWidgets('BackButton icon', (WidgetTester tester) async { final Key androidKey = UniqueKey(); final Key iOSKey = UniqueKey(); + final Key linuxKey = UniqueKey(); final Key macOSKey = UniqueKey(); + final Key windowsKey = UniqueKey(); await tester.pumpWidget( MaterialApp( @@ -82,10 +84,18 @@ void main() { data: ThemeData(platform: TargetPlatform.iOS), child: BackButtonIcon(key: iOSKey), ), + Theme( + data: ThemeData(platform: TargetPlatform.linux), + child: BackButtonIcon(key: linuxKey), + ), Theme( data: ThemeData(platform: TargetPlatform.macOS), child: BackButtonIcon(key: macOSKey), ), + Theme( + data: ThemeData(platform: TargetPlatform.windows), + child: BackButtonIcon(key: windowsKey), + ), ], ), ), @@ -93,10 +103,14 @@ void main() { final Icon androidIcon = tester.widget(find.descendant(of: find.byKey(androidKey), matching: find.byType(Icon))); final Icon iOSIcon = tester.widget(find.descendant(of: find.byKey(iOSKey), matching: find.byType(Icon))); + final Icon linuxIcon = tester.widget(find.descendant(of: find.byKey(linuxKey), matching: find.byType(Icon))); final Icon macOSIcon = tester.widget(find.descendant(of: find.byKey(macOSKey), matching: find.byType(Icon))); + final Icon windowsIcon = tester.widget(find.descendant(of: find.byKey(windowsKey), matching: find.byType(Icon))); expect(iOSIcon.icon == androidIcon.icon, isFalse); + expect(linuxIcon.icon == androidIcon.icon, isTrue); expect(macOSIcon.icon == androidIcon.icon, isFalse); expect(macOSIcon.icon == iOSIcon.icon, isTrue); + expect(windowsIcon.icon == androidIcon.icon, isTrue); }); testWidgets('BackButton color', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart b/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart index d31086daa5..40f37591c0 100644 --- a/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart @@ -47,7 +47,7 @@ void main() { expect(topBeforeScroll.dy, equals(0.0)); expect(topAfterScroll.dy, equals(0.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS })); + }, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform value) => value != TargetPlatform.fuchsia).toSet())); testWidgets('FlexibleSpaceBar collapse mode pin', (WidgetTester tester) async { await tester.pumpWidget( @@ -85,7 +85,7 @@ void main() { expect(topBeforeScroll.dy, equals(0.0)); expect(topAfterScroll.dy, equals(-100.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS })); + }, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform value) => value != TargetPlatform.fuchsia).toSet())); testWidgets('FlexibleSpaceBar collapse mode parallax', (WidgetTester tester) async { await tester.pumpWidget( @@ -124,7 +124,7 @@ void main() { expect(topBeforeScroll.dy, equals(0.0)); expect(topAfterScroll.dy, lessThan(10.0)); expect(topAfterScroll.dy, greaterThan(-50.0)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS })); + }, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform value) => value != TargetPlatform.fuchsia).toSet())); } Future slowDrag(WidgetTester tester, Key widget, Offset offset) async { diff --git a/packages/flutter/test/material/flexible_space_bar_test.dart b/packages/flutter/test/material/flexible_space_bar_test.dart index c8ac87271e..c70a08db81 100644 --- a/packages/flutter/test/material/flexible_space_bar_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_test.dart @@ -198,7 +198,7 @@ void main() { await tester.pumpWidget(buildFrame(TargetPlatform.android, true)); expect(getTitleBottomLeft(), const Offset(390.0, 0.0)); - // Clear the widget tree to avoid animating between Android and iOS. + // Clear the widget tree to avoid animating between platforms. await tester.pumpWidget(Container(key: UniqueKey())); await tester.pumpWidget(buildFrame(TargetPlatform.iOS, null)); @@ -207,7 +207,7 @@ void main() { await tester.pumpWidget(buildFrame(TargetPlatform.iOS, false)); expect(getTitleBottomLeft(), Offset.zero); - // Clear the widget tree to avoid animating between iOS and macOS. + // Clear the widget tree to avoid animating between platforms. await tester.pumpWidget(Container(key: UniqueKey())); await tester.pumpWidget(buildFrame(TargetPlatform.macOS, null)); @@ -215,6 +215,24 @@ void main() { await tester.pumpWidget(buildFrame(TargetPlatform.macOS, false)); expect(getTitleBottomLeft(), Offset.zero); + + // Clear the widget tree to avoid animating between platforms. + await tester.pumpWidget(Container(key: UniqueKey())); + + await tester.pumpWidget(buildFrame(TargetPlatform.windows, null)); + expect(getTitleBottomLeft(), Offset.zero); + + await tester.pumpWidget(buildFrame(TargetPlatform.windows, true)); + expect(getTitleBottomLeft(), const Offset(390.0, 0.0)); + + // Clear the widget tree to avoid animating between platforms. + await tester.pumpWidget(Container(key: UniqueKey())); + + await tester.pumpWidget(buildFrame(TargetPlatform.linux, null)); + expect(getTitleBottomLeft(), Offset.zero); + + await tester.pumpWidget(buildFrame(TargetPlatform.linux, true)); + expect(getTitleBottomLeft(), const Offset(390.0, 0.0)); }, skip: isBrowser); } diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index 96451b05fe..3dd11ff291 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -1250,7 +1250,7 @@ void main() { )); semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); testWidgets('Slider Semantics', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); @@ -1497,7 +1497,7 @@ void main() { await gesture.up(); } - for (final TargetPlatform platform in [TargetPlatform.android, TargetPlatform.fuchsia]) { + for (final TargetPlatform platform in [TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows]) { value = 0.5; await tester.pumpWidget(buildFrame(platform)); await tester.pumpAndSettle(); // Finish the theme change animation. diff --git a/packages/flutter/test/material/switch_list_tile_test.dart b/packages/flutter/test/material/switch_list_tile_test.dart index 11c1f810dc..a2c76c91f5 100644 --- a/packages/flutter/test/material/switch_list_tile_test.dart +++ b/packages/flutter/test/material/switch_list_tile_test.dart @@ -96,7 +96,7 @@ void main() { expect(value, isTrue, reason: 'on ${describeEnum(platform)}'); } - for (final TargetPlatform platform in [ TargetPlatform.android, TargetPlatform.fuchsia ]) { + for (final TargetPlatform platform in [ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows ]) { value = false; await tester.pumpWidget(buildFrame(platform)); await tester.pumpAndSettle(); // Finish the theme change animation. diff --git a/packages/flutter/test/material/switch_test.dart b/packages/flutter/test/material/switch_test.dart index 222ab59140..4f5cb22826 100644 --- a/packages/flutter/test/material/switch_test.dart +++ b/packages/flutter/test/material/switch_test.dart @@ -623,7 +623,7 @@ void main() { expect(value, isTrue, reason: 'on ${describeEnum(platform)}'); } - for (final TargetPlatform platform in [ TargetPlatform.android, TargetPlatform.fuchsia ]) { + for (final TargetPlatform platform in [ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows ]) { value = false; await tester.pumpWidget(buildFrame(platform)); await tester.pumpAndSettle(); // Finish the theme change animation. diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index b851ccab89..ab9930d2ea 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -663,7 +663,7 @@ void main() { expect(find.text('COPY'), findsOneWidget); expect(find.text('CUT'), findsNothing); expect(find.text('SELECT ALL'), findsNothing); - }, skip: isBrowser, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, skip: isBrowser, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); testWidgets('cursor layout has correct width', (WidgetTester tester) async { EditableText.debugDeterministicCursor = true; @@ -1125,7 +1125,7 @@ void main() { matching: find.byType(Container), )); expect(container.size, Size.zero); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); testWidgets('Sawping controllers should update selection', (WidgetTester tester) async { TextEditingController controller = TextEditingController(text: 'readonly'); @@ -5662,7 +5662,7 @@ void main() { // But don't trigger the toolbar. expect(find.byType(FlatButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); testWidgets( 'two slow taps do not trigger a word selection', @@ -5787,7 +5787,7 @@ void main() { // Selected text shows 4 toolbar buttons: cut, copy, paste, select all expect(find.byType(FlatButton), findsNWidgets(4)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); testWidgets( 'double tap on top of cursor also selects word', @@ -5836,7 +5836,7 @@ void main() { // Selected text shows 4 toolbar buttons: cut, copy, paste, select all expect(find.byType(FlatButton), findsNWidgets(4)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); testWidgets( 'double double tap just shows the selection menu', @@ -6118,7 +6118,7 @@ void main() { // Collapsed toolbar shows 4 buttons: cut, copy, paste, select all expect(find.byType(FlatButton), findsNWidgets(4)); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); testWidgets( 'long press tap cannot initiate a double tap', @@ -6496,7 +6496,7 @@ void main() { await gesture.up(); await tester.pump(); expect(find.byType(FlatButton), findsNothing); - }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia })); + }, variant: const TargetPlatformVariant({ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); testWidgets('force press selects word', (WidgetTester tester) async { final TextEditingController controller = TextEditingController( diff --git a/packages/flutter/test/material/typography_test.dart b/packages/flutter/test/material/typography_test.dart index 5a13588fb7..62cc63ad75 100644 --- a/packages/flutter/test/material/typography_test.dart +++ b/packages/flutter/test/material/typography_test.dart @@ -16,55 +16,63 @@ void main() { } }); - test('Typography on Android, Fuchsia defaults to Roboto', () { + test('Typography on non-Apple platforms defaults to the correct font', () { expect(Typography.material2018(platform: TargetPlatform.android).black.headline6.fontFamily, 'Roboto'); expect(Typography.material2018(platform: TargetPlatform.fuchsia).black.headline6.fontFamily, 'Roboto'); + expect(Typography.material2018(platform: TargetPlatform.linux).black.headline6.fontFamily, 'Roboto'); + expect(Typography.material2018(platform: TargetPlatform.linux).black.headline6.fontFamilyFallback, ['Ubuntu', 'Cantarell', 'DejaVu Sans', 'Liberation Sans', 'Arial']); + expect(Typography.material2018(platform: TargetPlatform.windows).black.headline6.fontFamily, 'Segoe UI'); + expect(Typography.material2018(platform: TargetPlatform.android).white.headline6.fontFamily, 'Roboto'); + expect(Typography.material2018(platform: TargetPlatform.fuchsia).white.headline6.fontFamily, 'Roboto'); + expect(Typography.material2018(platform: TargetPlatform.linux).white.headline6.fontFamily, 'Roboto'); + expect(Typography.material2018(platform: TargetPlatform.linux).white.headline6.fontFamilyFallback, ['Ubuntu', 'Cantarell', 'DejaVu Sans', 'Liberation Sans', 'Arial']); + expect(Typography.material2018(platform: TargetPlatform.windows).white.headline6.fontFamily, 'Segoe UI'); }); // Ref: https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/ - final Matcher isDisplayFont = predicate((TextStyle s) { + final Matcher isSanFranciscoDisplayFont = predicate((TextStyle s) { return s.fontFamily == '.SF UI Display'; }, 'Uses SF Display font'); - final Matcher isTextFont = predicate((TextStyle s) { + final Matcher isSanFranciscoTextFont = predicate((TextStyle s) { return s.fontFamily == '.SF UI Text'; }, 'Uses SF Text font'); test('Typography on iOS defaults to the correct SF font family based on size', () { final Typography typography = Typography.material2018(platform: TargetPlatform.iOS); for (final TextTheme textTheme in [typography.black, typography.white]) { - expect(textTheme.headline1, isDisplayFont); - expect(textTheme.headline2, isDisplayFont); - expect(textTheme.headline3, isDisplayFont); - expect(textTheme.headline4, isDisplayFont); - expect(textTheme.headline5, isDisplayFont); - expect(textTheme.headline6, isDisplayFont); - expect(textTheme.subtitle1, isTextFont); - expect(textTheme.bodyText1, isTextFont); - expect(textTheme.bodyText2, isTextFont); - expect(textTheme.caption, isTextFont); - expect(textTheme.button, isTextFont); - expect(textTheme.subtitle2, isTextFont); - expect(textTheme.overline, isTextFont); + expect(textTheme.headline1, isSanFranciscoDisplayFont); + expect(textTheme.headline2, isSanFranciscoDisplayFont); + expect(textTheme.headline3, isSanFranciscoDisplayFont); + expect(textTheme.headline4, isSanFranciscoDisplayFont); + expect(textTheme.headline5, isSanFranciscoDisplayFont); + expect(textTheme.headline6, isSanFranciscoDisplayFont); + expect(textTheme.subtitle1, isSanFranciscoTextFont); + expect(textTheme.bodyText1, isSanFranciscoTextFont); + expect(textTheme.bodyText2, isSanFranciscoTextFont); + expect(textTheme.caption, isSanFranciscoTextFont); + expect(textTheme.button, isSanFranciscoTextFont); + expect(textTheme.subtitle2, isSanFranciscoTextFont); + expect(textTheme.overline, isSanFranciscoTextFont); } }); test('Typography on macOS defaults to the correct SF font family based on size', () { final Typography typography = Typography.material2018(platform: TargetPlatform.macOS); for (final TextTheme textTheme in [typography.black, typography.white]) { - expect(textTheme.headline1, isDisplayFont); - expect(textTheme.headline2, isDisplayFont); - expect(textTheme.headline3, isDisplayFont); - expect(textTheme.headline4, isDisplayFont); - expect(textTheme.headline5, isDisplayFont); - expect(textTheme.headline6, isDisplayFont); - expect(textTheme.subtitle1, isTextFont); - expect(textTheme.bodyText1, isTextFont); - expect(textTheme.bodyText2, isTextFont); - expect(textTheme.caption, isTextFont); - expect(textTheme.button, isTextFont); - expect(textTheme.subtitle2, isTextFont); - expect(textTheme.overline, isTextFont); + expect(textTheme.headline1, isSanFranciscoDisplayFont); + expect(textTheme.headline2, isSanFranciscoDisplayFont); + expect(textTheme.headline3, isSanFranciscoDisplayFont); + expect(textTheme.headline4, isSanFranciscoDisplayFont); + expect(textTheme.headline5, isSanFranciscoDisplayFont); + expect(textTheme.headline6, isSanFranciscoDisplayFont); + expect(textTheme.subtitle1, isSanFranciscoTextFont); + expect(textTheme.bodyText1, isSanFranciscoTextFont); + expect(textTheme.bodyText2, isSanFranciscoTextFont); + expect(textTheme.caption, isSanFranciscoTextFont); + expect(textTheme.button, isSanFranciscoTextFont); + expect(textTheme.subtitle2, isSanFranciscoTextFont); + expect(textTheme.overline, isSanFranciscoTextFont); } }); diff --git a/packages/flutter/test/widgets/drawer_test.dart b/packages/flutter/test/widgets/drawer_test.dart index 70e73fb3a1..4d9714081a 100644 --- a/packages/flutter/test/widgets/drawer_test.dart +++ b/packages/flutter/test/widgets/drawer_test.dart @@ -357,7 +357,7 @@ void main() { expect(semantics, isNot(includesNodeWith(label: 'Dismiss'))); semantics.dispose(); - }, variant: const TargetPlatformVariant({ TargetPlatform.android })); + }, variant: TargetPlatformVariant.only(TargetPlatform.android)); testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); diff --git a/packages/flutter/test/widgets/scrollable_fling_test.dart b/packages/flutter/test/widgets/scrollable_fling_test.dart index b4e347047b..4a3744bd77 100644 --- a/packages/flutter/test/widgets/scrollable_fling_test.dart +++ b/packages/flutter/test/widgets/scrollable_fling_test.dart @@ -45,6 +45,22 @@ void main() { await tester.pump(const Duration(seconds: 5)); final double androidResult = getCurrentOffset(); + await pumpTest(tester, TargetPlatform.linux); + await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0); + expect(getCurrentOffset(), dragOffset); + await tester.pump(); // trigger fling + expect(getCurrentOffset(), dragOffset); + await tester.pump(const Duration(seconds: 5)); + final double linuxResult = getCurrentOffset(); + + await pumpTest(tester, TargetPlatform.windows); + await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0); + expect(getCurrentOffset(), dragOffset); + await tester.pump(); // trigger fling + expect(getCurrentOffset(), dragOffset); + await tester.pump(const Duration(seconds: 5)); + final double windowsResult = getCurrentOffset(); + await pumpTest(tester, TargetPlatform.iOS); await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0); // Scroll starts ease into the scroll on iOS. @@ -65,6 +81,14 @@ void main() { expect(androidResult, lessThan(iOSResult)); // iOS is slipperier than Android expect(androidResult, lessThan(macOSResult)); // macOS is slipperier than Android + expect(linuxResult, lessThan(iOSResult)); // iOS is slipperier than Linux + expect(linuxResult, lessThan(macOSResult)); // macOS is slipperier than Linux + expect(windowsResult, lessThan(iOSResult)); // iOS is slipperier than Windows + expect(windowsResult, lessThan(macOSResult)); // macOS is slipperier than Windows + expect(windowsResult, equals(androidResult)); + expect(windowsResult, equals(androidResult)); + expect(linuxResult, equals(androidResult)); + expect(linuxResult, equals(androidResult)); }); testWidgets('fling and tap to stop', (WidgetTester tester) async { diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index c5e6215dfe..79a7c26735 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -642,9 +642,6 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi 'web': web, 'macos': macos, 'year': DateTime.now().year, - // If a desktop platform is included, add a workaround for #31366. - // When Linux and Windows are added, we will need this workaround again. - 'includeTargetPlatformWorkaround': false, }; } diff --git a/packages/flutter_tools/templates/app/lib/main.dart.tmpl b/packages/flutter_tools/templates/app/lib/main.dart.tmpl index 3af0983f09..5a82f64575 100644 --- a/packages/flutter_tools/templates/app/lib/main.dart.tmpl +++ b/packages/flutter_tools/templates/app/lib/main.dart.tmpl @@ -1,8 +1,3 @@ -{{#includeTargetPlatformWorkaround}} -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -{{/includeTargetPlatformWorkaround}} import 'package:flutter/material.dart'; {{#withDriverTest}} import 'package:flutter_driver/driver_extension.dart'; @@ -13,39 +8,15 @@ import 'dart:async'; import 'package:flutter/services.dart'; import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart'; {{/withPluginHook}} -{{#includeTargetPlatformWorkaround}} -// Sets a platform override for desktop to avoid exceptions. See -// https://flutter.dev/desktop#target-platform-override for more info. -void _enablePlatformOverrideForDesktop() { - if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) { - debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - } -} -{{/includeTargetPlatformWorkaround}} - -{{^withDriverTest}} -{{^includeTargetPlatformWorkaround}} -void main() => runApp(MyApp()); -{{/includeTargetPlatformWorkaround}} -{{#includeTargetPlatformWorkaround}} void main() { - _enablePlatformOverrideForDesktop(); - runApp(MyApp()); -} -{{/includeTargetPlatformWorkaround}} -{{/withDriverTest}} {{#withDriverTest}} -void main() { -{{#includeTargetPlatformWorkaround}} - _enablePlatformOverrideForDesktop(); -{{/includeTargetPlatformWorkaround}} // Enable integration testing with the Flutter Driver extension. // See https://flutter.dev/testing/ for more info. enableFlutterDriverExtension(); +{{/withDriverTest}} runApp(MyApp()); } -{{/withDriverTest}} {{^withPluginHook}} class MyApp extends StatelessWidget {