Unverified Commit 1ba4f1f5 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Add Linux and Windows target platforms (#51519)

This PR adds the linux and windows target platform enum values, along with automatically setting the defaultTargetPlatform to the appropriate value on those platforms.

Fixes #31366
parent 7f6f08ad
...@@ -83,10 +83,14 @@ class _MyHomePageState extends State<_MyHomePage> { ...@@ -83,10 +83,14 @@ class _MyHomePageState extends State<_MyHomePage> {
return (await deviceInfo.androidInfo).model; return (await deviceInfo.androidInfo).model;
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
return 'fuchsia'; return 'fuchsia';
default: case TargetPlatform.macOS:
case TargetPlatform.linux:
case TargetPlatform.windows:
return 'unsupported'; return 'unsupported';
break;
} }
break; assert(false, 'Unhandled Theme target platform ${Theme.of(context).platform}.');
return 'unsupported';
} }
return 'unknown message: "$message"'; return 'unknown message: "$message"';
} }
......
...@@ -2,24 +2,12 @@ ...@@ -2,24 +2,12 @@
// 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.
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(const MaterialApp( runApp(const MaterialApp(
title: 'Actions Demo', title: 'Actions Demo',
home: FocusDemo(), home: FocusDemo(),
......
...@@ -2,9 +2,6 @@ ...@@ -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.
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class AnimatedIconsTestApp extends StatelessWidget { class AnimatedIconsTestApp extends StatelessWidget {
...@@ -108,16 +105,4 @@ class IconSample { ...@@ -108,16 +105,4 @@ class IconSample {
final String description; final String description;
} }
// Sets a platform override for desktop to avoid exceptions. See void main() => runApp(AnimatedIconsTestApp());
// 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());
}
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart' show timeDilation; import 'package:flutter/scheduler.dart' show timeDilation;
...@@ -24,19 +23,7 @@ final Map<int, Color> m2SwatchColors = <int, Color>{ ...@@ -24,19 +23,7 @@ final Map<int, Color> m2SwatchColors = <int, Color>{
}; };
final MaterialColor m2Swatch = MaterialColor(m2SwatchColors[500].value, m2SwatchColors); final MaterialColor m2Swatch = MaterialColor(m2SwatchColors[500].value, m2SwatchColors);
// Sets a platform override for desktop to avoid exceptions. See void main() => runApp(MyApp());
// 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());
}
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
static const String _title = 'Density Test'; static const String _title = 'Density Test';
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +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.
import 'dart:io';
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -296,17 +295,7 @@ class DragAndDropAppState extends State<DragAndDropApp> { ...@@ -296,17 +295,7 @@ class DragAndDropAppState extends State<DragAndDropApp> {
} }
} }
// 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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(MaterialApp( runApp(MaterialApp(
title: 'Drag and Drop Flutter Demo', title: 'Drag and Drop Flutter Demo',
home: DragAndDropApp(), home: DragAndDropApp(),
......
...@@ -2,24 +2,12 @@ ...@@ -2,24 +2,12 @@
// 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.
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(const MaterialApp( runApp(const MaterialApp(
title: 'Focus Demo', title: 'Focus Demo',
home: FocusDemo(), home: FocusDemo(),
......
...@@ -2,23 +2,11 @@ ...@@ -2,23 +2,11 @@
// 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.
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(const MaterialApp( runApp(const MaterialApp(
title: 'Hover Demo', title: 'Hover Demo',
home: HoverDemo(), home: HoverDemo(),
......
...@@ -2,22 +2,9 @@ ...@@ -2,22 +2,9 @@
// 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.
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(const Directionality( runApp(const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center( child: Center(
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
...@@ -475,17 +474,7 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM ...@@ -475,17 +474,7 @@ class _AnimationDemoState extends State<AnimationDemo> 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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(const MaterialApp( runApp(const MaterialApp(
home: AnimationDemo(), home: AnimationDemo(),
)); ));
......
...@@ -2,8 +2,6 @@ ...@@ -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.
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -206,17 +204,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> { ...@@ -206,17 +204,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
} }
} }
// 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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(MaterialApp( runApp(MaterialApp(
theme: ThemeData( theme: ThemeData(
brightness: Brightness.light, brightness: Brightness.light,
......
...@@ -2,8 +2,6 @@ ...@@ -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.
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -141,17 +139,7 @@ class PageViewAppState extends State<PageViewApp> { ...@@ -141,17 +139,7 @@ class PageViewAppState extends State<PageViewApp> {
} }
} }
// 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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(MaterialApp( runApp(MaterialApp(
title: 'PageView', title: 'PageView',
theme: ThemeData( theme: ThemeData(
......
...@@ -2,23 +2,11 @@ ...@@ -2,23 +2,11 @@
// 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.
import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(MaterialApp( runApp(MaterialApp(
title: 'Hardware Key Demo', title: 'Hardware Key Demo',
home: Scaffold( home: Scaffold(
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +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.
import 'dart:io';
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -12,17 +11,7 @@ import 'package:flutter/scheduler.dart'; ...@@ -12,17 +11,7 @@ import 'package:flutter/scheduler.dart';
int seed = 0; 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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(MaterialApp( runApp(MaterialApp(
title: 'Text tester', title: 'Text tester',
home: const Home(), home: const Home(),
......
...@@ -62,6 +62,8 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -62,6 +62,8 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
switch (Theme.of(context).platform) { switch (Theme.of(context).platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return Icons.arrow_back; return Icons.arrow_back;
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
......
...@@ -413,8 +413,12 @@ class _PlatformItem extends StatelessWidget { ...@@ -413,8 +413,12 @@ class _PlatformItem extends StatelessWidget {
return 'Fuchsia'; return 'Fuchsia';
case TargetPlatform.iOS: case TargetPlatform.iOS:
return 'Cupertino'; return 'Cupertino';
case TargetPlatform.linux:
return 'Material Desktop (linux)';
case TargetPlatform.macOS: case TargetPlatform.macOS:
return 'Material Desktop (macOS)'; return 'Material Desktop (macOS)';
case TargetPlatform.windows:
return 'Material Desktop (Windows)';
} }
assert(false); assert(false);
return null; return null;
......
...@@ -234,7 +234,9 @@ class _CupertinoPickerState extends State<CupertinoPicker> { ...@@ -234,7 +234,9 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.windows:
hasSuitableHapticHardware = false; hasSuitableHapticHardware = false;
break; break;
} }
......
...@@ -456,7 +456,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ...@@ -456,7 +456,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.windows:
break; break;
} }
} }
......
...@@ -9,14 +9,18 @@ import 'platform.dart' as platform; ...@@ -9,14 +9,18 @@ import 'platform.dart' as platform;
/// The dart:io implementation of [platform.defaultTargetPlatform]. /// The dart:io implementation of [platform.defaultTargetPlatform].
platform.TargetPlatform get defaultTargetPlatform { platform.TargetPlatform get defaultTargetPlatform {
platform.TargetPlatform result; platform.TargetPlatform result;
if (Platform.isIOS) { if (Platform.isAndroid) {
result = platform.TargetPlatform.iOS;
} else if (Platform.isMacOS) {
result = platform.TargetPlatform.macOS;
} else if (Platform.isAndroid) {
result = platform.TargetPlatform.android; result = platform.TargetPlatform.android;
} else if (Platform.isIOS) {
result = platform.TargetPlatform.iOS;
} else if (Platform.isFuchsia) { } else if (Platform.isFuchsia) {
result = platform.TargetPlatform.fuchsia; 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(() { assert(() {
if (Platform.environment.containsKey('FLUTTER_TEST')) if (Platform.environment.containsKey('FLUTTER_TEST'))
......
...@@ -161,14 +161,20 @@ abstract class BindingBase { ...@@ -161,14 +161,20 @@ abstract class BindingBase {
case 'android': case 'android':
debugDefaultTargetPlatformOverride = TargetPlatform.android; debugDefaultTargetPlatformOverride = TargetPlatform.android;
break; break;
case 'fuchsia':
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
break;
case 'iOS': case 'iOS':
debugDefaultTargetPlatformOverride = TargetPlatform.iOS; debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
break; break;
case 'linux':
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
break;
case 'macOS': case 'macOS':
debugDefaultTargetPlatformOverride = TargetPlatform.macOS; debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
break; break;
case 'fuchsia': case 'windows':
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; debugDefaultTargetPlatformOverride = TargetPlatform.windows;
break; break;
case 'default': case 'default':
default: default:
......
...@@ -45,11 +45,17 @@ enum TargetPlatform { ...@@ -45,11 +45,17 @@ enum TargetPlatform {
/// Fuchsia: <https://fuchsia.googlesource.com/> /// Fuchsia: <https://fuchsia.googlesource.com/>
fuchsia, fuchsia,
/// iOS: <http://www.apple.com/ios/> /// iOS: <https://www.apple.com/ios/>
iOS, iOS,
/// macOS: <http://www.apple.com/macos> /// Linux: <https://www.linux.org>
linux,
/// macOS: <https://www.apple.com/macos>
macOS, macOS,
/// Windows: <https://www.windows.com>
windows,
} }
/// Override the [defaultTargetPlatform]. /// Override the [defaultTargetPlatform].
......
...@@ -548,7 +548,9 @@ class _MaterialScrollBehavior extends ScrollBehavior { ...@@ -548,7 +548,9 @@ class _MaterialScrollBehavior extends ScrollBehavior {
// the base class as well. // the base class as well.
switch (getPlatform(context)) { switch (getPlatform(context)) {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.linux:
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.windows:
return child; return child;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
......
...@@ -426,6 +426,8 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { ...@@ -426,6 +426,8 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
switch (theme.platform) { switch (theme.platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return false; return false;
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
...@@ -516,6 +518,8 @@ class _AppBarState extends State<AppBar> { ...@@ -516,6 +518,8 @@ class _AppBarState extends State<AppBar> {
switch (theme.platform) { switch (theme.platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
namesRoute = true; namesRoute = true;
break; break;
case TargetPlatform.iOS: case TargetPlatform.iOS:
......
...@@ -32,6 +32,8 @@ class BackButtonIcon extends StatelessWidget { ...@@ -32,6 +32,8 @@ class BackButtonIcon extends StatelessWidget {
switch (platform) { switch (platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return Icons.arrow_back; return Icons.arrow_back;
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
......
...@@ -339,6 +339,8 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { ...@@ -339,6 +339,8 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
return ''; return '';
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return localizations.dialogLabel; return localizations.dialogLabel;
} }
return null; return null;
......
...@@ -908,6 +908,8 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { ...@@ -908,6 +908,8 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
switch (Theme.of(context).platform) { switch (Theme.of(context).platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
HapticFeedback.vibrate(); HapticFeedback.vibrate();
break; break;
case TargetPlatform.iOS: case TargetPlatform.iOS:
......
...@@ -464,6 +464,8 @@ class AlertDialog extends StatelessWidget { ...@@ -464,6 +464,8 @@ class AlertDialog extends StatelessWidget {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
label = semanticLabel ?? MaterialLocalizations.of(context)?.alertDialogLabel; label = semanticLabel ?? MaterialLocalizations.of(context)?.alertDialogLabel;
} }
} }
...@@ -794,6 +796,8 @@ class SimpleDialog extends StatelessWidget { ...@@ -794,6 +796,8 @@ class SimpleDialog extends StatelessWidget {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
label = semanticLabel ?? MaterialLocalizations.of(context)?.dialogLabel; label = semanticLabel ?? MaterialLocalizations.of(context)?.dialogLabel;
} }
} }
......
...@@ -182,6 +182,8 @@ class Drawer extends StatelessWidget { ...@@ -182,6 +182,8 @@ class Drawer extends StatelessWidget {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
label = semanticLabel ?? MaterialLocalizations.of(context)?.drawerLabel; label = semanticLabel ?? MaterialLocalizations.of(context)?.drawerLabel;
} }
return Semantics( return Semantics(
...@@ -536,6 +538,8 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro ...@@ -536,6 +538,8 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
platformHasBackButton = false; platformHasBackButton = false;
break; break;
} }
......
...@@ -99,9 +99,15 @@ class Feedback { ...@@ -99,9 +99,15 @@ class Feedback {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
return SystemSound.play(SystemSoundType.click); return SystemSound.play(SystemSoundType.click);
default: case TargetPlatform.iOS:
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
return Future<void>.value(); return Future<void>.value();
break;
} }
assert(false, 'Unhandled TargetPlatform ${_platform(context)}');
return Future<void>.value();
} }
/// Wraps a [GestureTapCallback] to provide platform specific feedback for a /// Wraps a [GestureTapCallback] to provide platform specific feedback for a
...@@ -138,9 +144,15 @@ class Feedback { ...@@ -138,9 +144,15 @@ class Feedback {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
return HapticFeedback.vibrate(); return HapticFeedback.vibrate();
default: case TargetPlatform.iOS:
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
return Future<void>.value(); return Future<void>.value();
break;
} }
assert(false, 'Unhandled TargetPlatform ${_platform(context)}');
return Future<void>.value();
} }
/// Wraps a [GestureLongPressCallback] to provide platform specific feedback /// Wraps a [GestureLongPressCallback] to provide platform specific feedback
......
...@@ -237,6 +237,8 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> { ...@@ -237,6 +237,8 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
switch (theme.platform) { switch (theme.platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return false; return false;
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
...@@ -345,8 +347,10 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> { ...@@ -345,8 +347,10 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
case TargetPlatform.macOS: case TargetPlatform.macOS:
title = widget.title; title = widget.title;
break; break;
case TargetPlatform.fuchsia:
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
title = Semantics( title = Semantics(
namesRoute: true, namesRoute: true,
child: widget.title, child: widget.title,
......
...@@ -494,7 +494,9 @@ class PageTransitionsTheme extends Diagnosticable { ...@@ -494,7 +494,9 @@ class PageTransitionsTheme extends Diagnosticable {
static const Map<TargetPlatform, PageTransitionsBuilder> _defaultBuilders = <TargetPlatform, PageTransitionsBuilder>{ static const Map<TargetPlatform, PageTransitionsBuilder> _defaultBuilders = <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.linux: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(), TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(),
}; };
/// The [PageTransitionsBuilder]s supported by this theme. /// The [PageTransitionsBuilder]s supported by this theme.
......
...@@ -837,6 +837,8 @@ Future<T> showMenu<T>({ ...@@ -837,6 +837,8 @@ Future<T> showMenu<T>({
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
label = semanticLabel ?? MaterialLocalizations.of(context)?.popupMenuLabel; label = semanticLabel ?? MaterialLocalizations.of(context)?.popupMenuLabel;
} }
...@@ -1096,6 +1098,8 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> { ...@@ -1096,6 +1098,8 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
switch (platform) { switch (platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return const Icon(Icons.more_vert); return const Icon(Icons.more_vert);
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
......
...@@ -903,10 +903,14 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ...@@ -903,10 +903,14 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
return 0.1; return 0.1;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
default: case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
// Matches Android implementation of material slider. // Matches Android implementation of material slider.
return 0.05; return 0.05;
} }
assert(false, 'Unhandled TargetPlatform $_platform');
return 0.05;
} }
void _updateLabelPainters() { void _updateLabelPainters() {
......
...@@ -2498,6 +2498,8 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin { ...@@ -2498,6 +2498,8 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
break; break;
} }
......
...@@ -96,6 +96,8 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin { ...@@ -96,6 +96,8 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
_themeColor = theme.highlightColor.withOpacity(1.0); _themeColor = theme.highlightColor.withOpacity(1.0);
_textDirection = Directionality.of(context); _textDirection = Directionality.of(context);
_materialPainter = _buildMaterialScrollbarPainter(); _materialPainter = _buildMaterialScrollbarPainter();
......
...@@ -492,6 +492,8 @@ class _SearchPageState<T> extends State<_SearchPage<T>> { ...@@ -492,6 +492,8 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
routeName = searchFieldLabel; routeName = searchFieldLabel;
} }
......
...@@ -78,6 +78,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur ...@@ -78,6 +78,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
renderEditable.selectWordsInRange( renderEditable.selectWordsInRange(
from: details.globalPosition - details.offsetFromOrigin, from: details.globalPosition - details.offsetFromOrigin,
to: details.globalPosition, to: details.globalPosition,
...@@ -99,6 +101,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur ...@@ -99,6 +101,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
renderEditable.selectPosition(cause: SelectionChangedCause.tap); renderEditable.selectPosition(cause: SelectionChangedCause.tap);
break; break;
} }
...@@ -120,6 +124,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur ...@@ -120,6 +124,8 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
renderEditable.selectWord(cause: SelectionChangedCause.longPress); renderEditable.selectWord(cause: SelectionChangedCause.longPress);
Feedback.forLongPress(_state.context); Feedback.forLongPress(_state.context);
break; break;
...@@ -494,6 +500,8 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive ...@@ -494,6 +500,8 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
return; return;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
// Do nothing. // Do nothing.
} }
} }
...@@ -567,6 +575,8 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive ...@@ -567,6 +575,8 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
forcePressEnabled = false; forcePressEnabled = false;
textSelectionControls = materialTextSelectionControls; textSelectionControls = materialTextSelectionControls;
paintCursorAboveText = false; paintCursorAboveText = false;
......
...@@ -502,6 +502,8 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin { ...@@ -502,6 +502,8 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
switch (theme.platform) { switch (theme.platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return _buildMaterialSlider(context); return _buildMaterialSlider(context);
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
...@@ -892,13 +894,16 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -892,13 +894,16 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
switch (_platform) { switch (_platform) {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
// Matches iOS implementation of material slider. // Matches iOS implementation of material slider.
return 0.1; return 0.1;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
// Matches Android implementation of material slider. case TargetPlatform.linux:
case TargetPlatform.windows:
// Matches Android implementation of material slider.
return 0.05; return 0.05;
} }
assert(false, 'Unhandled TargetPlatform $_platform');
return 0.0; return 0.0;
} }
......
...@@ -352,6 +352,8 @@ class _SwitchState extends State<Switch> with TickerProviderStateMixin { ...@@ -352,6 +352,8 @@ class _SwitchState extends State<Switch> with TickerProviderStateMixin {
switch (theme.platform) { switch (theme.platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return buildMaterialSwitch(context); return buildMaterialSwitch(context);
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.macOS: case TargetPlatform.macOS:
......
...@@ -69,6 +69,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete ...@@ -69,6 +69,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
renderEditable.selectWordsInRange( renderEditable.selectWordsInRange(
from: details.globalPosition - details.offsetFromOrigin, from: details.globalPosition - details.offsetFromOrigin,
to: details.globalPosition, to: details.globalPosition,
...@@ -90,6 +92,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete ...@@ -90,6 +92,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
renderEditable.selectPosition(cause: SelectionChangedCause.tap); renderEditable.selectPosition(cause: SelectionChangedCause.tap);
break; break;
} }
...@@ -112,6 +116,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete ...@@ -112,6 +116,8 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
renderEditable.selectWord(cause: SelectionChangedCause.longPress); renderEditable.selectWord(cause: SelectionChangedCause.longPress);
Feedback.forLongPress(_state.context); Feedback.forLongPress(_state.context);
break; break;
...@@ -919,6 +925,8 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe ...@@ -919,6 +925,8 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe
return; return;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
// Do nothing. // Do nothing.
} }
} }
...@@ -980,6 +988,8 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe ...@@ -980,6 +988,8 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
forcePressEnabled = false; forcePressEnabled = false;
textSelectionControls = materialTextSelectionControls; textSelectionControls = materialTextSelectionControls;
paintCursorAboveText = false; paintCursorAboveText = false;
......
...@@ -206,6 +206,8 @@ class _DayPeriodControl extends StatelessWidget { ...@@ -206,6 +206,8 @@ class _DayPeriodControl extends StatelessWidget {
switch (fragmentContext.targetPlatform) { switch (fragmentContext.targetPlatform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
_announceToAccessibility(context, MaterialLocalizations.of(context).anteMeridiemAbbreviation); _announceToAccessibility(context, MaterialLocalizations.of(context).anteMeridiemAbbreviation);
break; break;
case TargetPlatform.iOS: case TargetPlatform.iOS:
...@@ -222,6 +224,8 @@ class _DayPeriodControl extends StatelessWidget { ...@@ -222,6 +224,8 @@ class _DayPeriodControl extends StatelessWidget {
switch (fragmentContext.targetPlatform) { switch (fragmentContext.targetPlatform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
_announceToAccessibility(context, MaterialLocalizations.of(context).postMeridiemAbbreviation); _announceToAccessibility(context, MaterialLocalizations.of(context).postMeridiemAbbreviation);
break; break;
case TargetPlatform.iOS: case TargetPlatform.iOS:
...@@ -1535,6 +1539,8 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { ...@@ -1535,6 +1539,8 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
switch (Theme.of(context).platform) { switch (Theme.of(context).platform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
_vibrateTimer?.cancel(); _vibrateTimer?.cancel();
_vibrateTimer = Timer(_kVibrateCommitDelay, () { _vibrateTimer = Timer(_kVibrateCommitDelay, () {
HapticFeedback.vibrate(); HapticFeedback.vibrate();
......
...@@ -1732,6 +1732,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -1732,6 +1732,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
return Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight + 2); return Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight + 2);
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return Rect.fromLTWH(0.0, _kCaretHeightOffset, cursorWidth, preferredLineHeight - 2.0 * _kCaretHeightOffset); return Rect.fromLTWH(0.0, _kCaretHeightOffset, cursorWidth, preferredLineHeight - 2.0 * _kCaretHeightOffset);
} }
return null; return null;
...@@ -1800,6 +1802,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -1800,6 +1802,8 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
break; break;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
// Override the height to take the full height of the glyph at the TextPosition // 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. // when not on iOS. iOS has special handling that creates a taller caret.
// TODO(garyq): See the TODO for _getCaretPrototype. // TODO(garyq): See the TODO for _getCaretPrototype.
......
...@@ -255,7 +255,9 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -255,7 +255,9 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
break; break;
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.linux:
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.windows:
break; break;
} }
// If there are no overlay styles in the UI don't bother updating. // If there are no overlay styles in the UI don't bother updating.
......
...@@ -919,6 +919,8 @@ class WidgetsApp extends StatefulWidget { ...@@ -919,6 +919,8 @@ class WidgetsApp extends StatefulWidget {
switch (defaultTargetPlatform) { switch (defaultTargetPlatform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return _defaultShortcuts; return _defaultShortcuts;
case TargetPlatform.macOS: case TargetPlatform.macOS:
return _defaultMacOsShortcuts; return _defaultMacOsShortcuts;
......
...@@ -79,6 +79,8 @@ class ModalBarrier extends StatelessWidget { ...@@ -79,6 +79,8 @@ class ModalBarrier extends StatelessWidget {
switch (defaultTargetPlatform) { switch (defaultTargetPlatform) {
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
platformSupportsDismissingBarrier = false; platformSupportsDismissingBarrier = false;
break; break;
case TargetPlatform.iOS: case TargetPlatform.iOS:
......
...@@ -35,7 +35,9 @@ class ScrollBehavior { ...@@ -35,7 +35,9 @@ class ScrollBehavior {
// _MaterialScrollBehavior as well. // _MaterialScrollBehavior as well.
switch (getPlatform(context)) { switch (getPlatform(context)) {
case TargetPlatform.iOS: case TargetPlatform.iOS:
case TargetPlatform.linux:
case TargetPlatform.macOS: case TargetPlatform.macOS:
case TargetPlatform.windows:
return child; return child;
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
...@@ -59,6 +61,8 @@ class ScrollBehavior { ...@@ -59,6 +61,8 @@ class ScrollBehavior {
return const BouncingScrollPhysics(); return const BouncingScrollPhysics();
case TargetPlatform.android: case TargetPlatform.android:
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return const ClampingScrollPhysics(); return const ClampingScrollPhysics();
} }
return null; return null;
......
...@@ -530,11 +530,27 @@ void main() { ...@@ -530,11 +530,27 @@ void main() {
extensionChangedEvent = extensionChangedEvents.last; extensionChangedEvent = extensionChangedEvents.last;
expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride');
expect(extensionChangedEvent['value'], 'iOS'); expect(extensionChangedEvent['value'], 'iOS');
result = await hasReassemble(binding.testExtension('platformOverride', <String, String>{'value': 'linux'}));
expect(result, <String, String>{'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', <String, String>{'value': 'windows'}));
expect(result, <String, String>{'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', <String, String>{'value': 'bogus'})); result = await hasReassemble(binding.testExtension('platformOverride', <String, String>{'value': 'bogus'}));
expect(result, <String, String>{'value': 'android'}); expect(result, <String, String>{'value': 'android'});
expect(binding.reassembled, 7); expect(binding.reassembled, 9);
expect(defaultTargetPlatform, TargetPlatform.android); expect(defaultTargetPlatform, TargetPlatform.android);
expect(extensionChangedEvents.length, 7); expect(extensionChangedEvents.length, 9);
extensionChangedEvent = extensionChangedEvents.last; extensionChangedEvent = extensionChangedEvents.last;
expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride'); expect(extensionChangedEvent['extension'], 'ext.flutter.platformOverride');
expect(extensionChangedEvent['value'], 'android'); expect(extensionChangedEvent['value'], 'android');
......
...@@ -68,7 +68,9 @@ void main() { ...@@ -68,7 +68,9 @@ void main() {
testWidgets('BackButton icon', (WidgetTester tester) async { testWidgets('BackButton icon', (WidgetTester tester) async {
final Key androidKey = UniqueKey(); final Key androidKey = UniqueKey();
final Key iOSKey = UniqueKey(); final Key iOSKey = UniqueKey();
final Key linuxKey = UniqueKey();
final Key macOSKey = UniqueKey(); final Key macOSKey = UniqueKey();
final Key windowsKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -82,10 +84,18 @@ void main() { ...@@ -82,10 +84,18 @@ void main() {
data: ThemeData(platform: TargetPlatform.iOS), data: ThemeData(platform: TargetPlatform.iOS),
child: BackButtonIcon(key: iOSKey), child: BackButtonIcon(key: iOSKey),
), ),
Theme(
data: ThemeData(platform: TargetPlatform.linux),
child: BackButtonIcon(key: linuxKey),
),
Theme( Theme(
data: ThemeData(platform: TargetPlatform.macOS), data: ThemeData(platform: TargetPlatform.macOS),
child: BackButtonIcon(key: macOSKey), child: BackButtonIcon(key: macOSKey),
), ),
Theme(
data: ThemeData(platform: TargetPlatform.windows),
child: BackButtonIcon(key: windowsKey),
),
], ],
), ),
), ),
...@@ -93,10 +103,14 @@ void main() { ...@@ -93,10 +103,14 @@ void main() {
final Icon androidIcon = tester.widget(find.descendant(of: find.byKey(androidKey), matching: find.byType(Icon))); 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 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 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(iOSIcon.icon == androidIcon.icon, isFalse);
expect(linuxIcon.icon == androidIcon.icon, isTrue);
expect(macOSIcon.icon == androidIcon.icon, isFalse); expect(macOSIcon.icon == androidIcon.icon, isFalse);
expect(macOSIcon.icon == iOSIcon.icon, isTrue); expect(macOSIcon.icon == iOSIcon.icon, isTrue);
expect(windowsIcon.icon == androidIcon.icon, isTrue);
}); });
testWidgets('BackButton color', (WidgetTester tester) async { testWidgets('BackButton color', (WidgetTester tester) async {
......
...@@ -47,7 +47,7 @@ void main() { ...@@ -47,7 +47,7 @@ void main() {
expect(topBeforeScroll.dy, equals(0.0)); expect(topBeforeScroll.dy, equals(0.0));
expect(topAfterScroll.dy, equals(0.0)); expect(topAfterScroll.dy, equals(0.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ 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 { testWidgets('FlexibleSpaceBar collapse mode pin', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
...@@ -85,7 +85,7 @@ void main() { ...@@ -85,7 +85,7 @@ void main() {
expect(topBeforeScroll.dy, equals(0.0)); expect(topBeforeScroll.dy, equals(0.0));
expect(topAfterScroll.dy, equals(-100.0)); expect(topAfterScroll.dy, equals(-100.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ 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 { testWidgets('FlexibleSpaceBar collapse mode parallax', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
...@@ -124,7 +124,7 @@ void main() { ...@@ -124,7 +124,7 @@ void main() {
expect(topBeforeScroll.dy, equals(0.0)); expect(topBeforeScroll.dy, equals(0.0));
expect(topAfterScroll.dy, lessThan(10.0)); expect(topAfterScroll.dy, lessThan(10.0));
expect(topAfterScroll.dy, greaterThan(-50.0)); expect(topAfterScroll.dy, greaterThan(-50.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform value) => value != TargetPlatform.fuchsia).toSet()));
} }
Future<void> slowDrag(WidgetTester tester, Key widget, Offset offset) async { Future<void> slowDrag(WidgetTester tester, Key widget, Offset offset) async {
......
...@@ -198,7 +198,7 @@ void main() { ...@@ -198,7 +198,7 @@ void main() {
await tester.pumpWidget(buildFrame(TargetPlatform.android, true)); await tester.pumpWidget(buildFrame(TargetPlatform.android, true));
expect(getTitleBottomLeft(), const Offset(390.0, 0.0)); 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(Container(key: UniqueKey()));
await tester.pumpWidget(buildFrame(TargetPlatform.iOS, null)); await tester.pumpWidget(buildFrame(TargetPlatform.iOS, null));
...@@ -207,7 +207,7 @@ void main() { ...@@ -207,7 +207,7 @@ void main() {
await tester.pumpWidget(buildFrame(TargetPlatform.iOS, false)); await tester.pumpWidget(buildFrame(TargetPlatform.iOS, false));
expect(getTitleBottomLeft(), Offset.zero); 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(Container(key: UniqueKey()));
await tester.pumpWidget(buildFrame(TargetPlatform.macOS, null)); await tester.pumpWidget(buildFrame(TargetPlatform.macOS, null));
...@@ -215,6 +215,24 @@ void main() { ...@@ -215,6 +215,24 @@ void main() {
await tester.pumpWidget(buildFrame(TargetPlatform.macOS, false)); await tester.pumpWidget(buildFrame(TargetPlatform.macOS, false));
expect(getTitleBottomLeft(), Offset.zero); 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); }, skip: isBrowser);
} }
......
...@@ -1250,7 +1250,7 @@ void main() { ...@@ -1250,7 +1250,7 @@ void main() {
)); ));
semantics.dispose(); semantics.dispose();
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets('Slider Semantics', (WidgetTester tester) async { testWidgets('Slider Semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
...@@ -1497,7 +1497,7 @@ void main() { ...@@ -1497,7 +1497,7 @@ void main() {
await gesture.up(); await gesture.up();
} }
for (final TargetPlatform platform in <TargetPlatform>[TargetPlatform.android, TargetPlatform.fuchsia]) { for (final TargetPlatform platform in <TargetPlatform>[TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows]) {
value = 0.5; value = 0.5;
await tester.pumpWidget(buildFrame(platform)); await tester.pumpWidget(buildFrame(platform));
await tester.pumpAndSettle(); // Finish the theme change animation. await tester.pumpAndSettle(); // Finish the theme change animation.
......
...@@ -96,7 +96,7 @@ void main() { ...@@ -96,7 +96,7 @@ void main() {
expect(value, isTrue, reason: 'on ${describeEnum(platform)}'); expect(value, isTrue, reason: 'on ${describeEnum(platform)}');
} }
for (final TargetPlatform platform in <TargetPlatform>[ TargetPlatform.android, TargetPlatform.fuchsia ]) { for (final TargetPlatform platform in <TargetPlatform>[ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows ]) {
value = false; value = false;
await tester.pumpWidget(buildFrame(platform)); await tester.pumpWidget(buildFrame(platform));
await tester.pumpAndSettle(); // Finish the theme change animation. await tester.pumpAndSettle(); // Finish the theme change animation.
......
...@@ -623,7 +623,7 @@ void main() { ...@@ -623,7 +623,7 @@ void main() {
expect(value, isTrue, reason: 'on ${describeEnum(platform)}'); expect(value, isTrue, reason: 'on ${describeEnum(platform)}');
} }
for (final TargetPlatform platform in <TargetPlatform>[ TargetPlatform.android, TargetPlatform.fuchsia ]) { for (final TargetPlatform platform in <TargetPlatform>[ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows ]) {
value = false; value = false;
await tester.pumpWidget(buildFrame(platform)); await tester.pumpWidget(buildFrame(platform));
await tester.pumpAndSettle(); // Finish the theme change animation. await tester.pumpAndSettle(); // Finish the theme change animation.
......
...@@ -663,7 +663,7 @@ void main() { ...@@ -663,7 +663,7 @@ void main() {
expect(find.text('COPY'), findsOneWidget); expect(find.text('COPY'), findsOneWidget);
expect(find.text('CUT'), findsNothing); expect(find.text('CUT'), findsNothing);
expect(find.text('SELECT ALL'), findsNothing); expect(find.text('SELECT ALL'), findsNothing);
}, skip: isBrowser, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia })); }, skip: isBrowser, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets('cursor layout has correct width', (WidgetTester tester) async { testWidgets('cursor layout has correct width', (WidgetTester tester) async {
EditableText.debugDeterministicCursor = true; EditableText.debugDeterministicCursor = true;
...@@ -1125,7 +1125,7 @@ void main() { ...@@ -1125,7 +1125,7 @@ void main() {
matching: find.byType(Container), matching: find.byType(Container),
)); ));
expect(container.size, Size.zero); expect(container.size, Size.zero);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets('Sawping controllers should update selection', (WidgetTester tester) async { testWidgets('Sawping controllers should update selection', (WidgetTester tester) async {
TextEditingController controller = TextEditingController(text: 'readonly'); TextEditingController controller = TextEditingController(text: 'readonly');
...@@ -5662,7 +5662,7 @@ void main() { ...@@ -5662,7 +5662,7 @@ void main() {
// But don't trigger the toolbar. // But don't trigger the toolbar.
expect(find.byType(FlatButton), findsNothing); expect(find.byType(FlatButton), findsNothing);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets( testWidgets(
'two slow taps do not trigger a word selection', 'two slow taps do not trigger a word selection',
...@@ -5787,7 +5787,7 @@ void main() { ...@@ -5787,7 +5787,7 @@ void main() {
// Selected text shows 4 toolbar buttons: cut, copy, paste, select all // Selected text shows 4 toolbar buttons: cut, copy, paste, select all
expect(find.byType(FlatButton), findsNWidgets(4)); expect(find.byType(FlatButton), findsNWidgets(4));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets( testWidgets(
'double tap on top of cursor also selects word', 'double tap on top of cursor also selects word',
...@@ -5836,7 +5836,7 @@ void main() { ...@@ -5836,7 +5836,7 @@ void main() {
// Selected text shows 4 toolbar buttons: cut, copy, paste, select all // Selected text shows 4 toolbar buttons: cut, copy, paste, select all
expect(find.byType(FlatButton), findsNWidgets(4)); expect(find.byType(FlatButton), findsNWidgets(4));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets( testWidgets(
'double double tap just shows the selection menu', 'double double tap just shows the selection menu',
...@@ -6118,7 +6118,7 @@ void main() { ...@@ -6118,7 +6118,7 @@ void main() {
// Collapsed toolbar shows 4 buttons: cut, copy, paste, select all // Collapsed toolbar shows 4 buttons: cut, copy, paste, select all
expect(find.byType(FlatButton), findsNWidgets(4)); expect(find.byType(FlatButton), findsNWidgets(4));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets( testWidgets(
'long press tap cannot initiate a double tap', 'long press tap cannot initiate a double tap',
...@@ -6496,7 +6496,7 @@ void main() { ...@@ -6496,7 +6496,7 @@ void main() {
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
expect(find.byType(FlatButton), findsNothing); expect(find.byType(FlatButton), findsNothing);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets('force press selects word', (WidgetTester tester) async { testWidgets('force press selects word', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController( final TextEditingController controller = TextEditingController(
......
...@@ -16,55 +16,63 @@ void main() { ...@@ -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.android).black.headline6.fontFamily, 'Roboto');
expect(Typography.material2018(platform: TargetPlatform.fuchsia).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, <String>['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, <String>['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/ // 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'; return s.fontFamily == '.SF UI Display';
}, 'Uses SF Display font'); }, 'Uses SF Display font');
final Matcher isTextFont = predicate((TextStyle s) { final Matcher isSanFranciscoTextFont = predicate((TextStyle s) {
return s.fontFamily == '.SF UI Text'; return s.fontFamily == '.SF UI Text';
}, 'Uses SF Text font'); }, 'Uses SF Text font');
test('Typography on iOS defaults to the correct SF font family based on size', () { test('Typography on iOS defaults to the correct SF font family based on size', () {
final Typography typography = Typography.material2018(platform: TargetPlatform.iOS); final Typography typography = Typography.material2018(platform: TargetPlatform.iOS);
for (final TextTheme textTheme in <TextTheme>[typography.black, typography.white]) { for (final TextTheme textTheme in <TextTheme>[typography.black, typography.white]) {
expect(textTheme.headline1, isDisplayFont); expect(textTheme.headline1, isSanFranciscoDisplayFont);
expect(textTheme.headline2, isDisplayFont); expect(textTheme.headline2, isSanFranciscoDisplayFont);
expect(textTheme.headline3, isDisplayFont); expect(textTheme.headline3, isSanFranciscoDisplayFont);
expect(textTheme.headline4, isDisplayFont); expect(textTheme.headline4, isSanFranciscoDisplayFont);
expect(textTheme.headline5, isDisplayFont); expect(textTheme.headline5, isSanFranciscoDisplayFont);
expect(textTheme.headline6, isDisplayFont); expect(textTheme.headline6, isSanFranciscoDisplayFont);
expect(textTheme.subtitle1, isTextFont); expect(textTheme.subtitle1, isSanFranciscoTextFont);
expect(textTheme.bodyText1, isTextFont); expect(textTheme.bodyText1, isSanFranciscoTextFont);
expect(textTheme.bodyText2, isTextFont); expect(textTheme.bodyText2, isSanFranciscoTextFont);
expect(textTheme.caption, isTextFont); expect(textTheme.caption, isSanFranciscoTextFont);
expect(textTheme.button, isTextFont); expect(textTheme.button, isSanFranciscoTextFont);
expect(textTheme.subtitle2, isTextFont); expect(textTheme.subtitle2, isSanFranciscoTextFont);
expect(textTheme.overline, isTextFont); expect(textTheme.overline, isSanFranciscoTextFont);
} }
}); });
test('Typography on macOS defaults to the correct SF font family based on size', () { test('Typography on macOS defaults to the correct SF font family based on size', () {
final Typography typography = Typography.material2018(platform: TargetPlatform.macOS); final Typography typography = Typography.material2018(platform: TargetPlatform.macOS);
for (final TextTheme textTheme in <TextTheme>[typography.black, typography.white]) { for (final TextTheme textTheme in <TextTheme>[typography.black, typography.white]) {
expect(textTheme.headline1, isDisplayFont); expect(textTheme.headline1, isSanFranciscoDisplayFont);
expect(textTheme.headline2, isDisplayFont); expect(textTheme.headline2, isSanFranciscoDisplayFont);
expect(textTheme.headline3, isDisplayFont); expect(textTheme.headline3, isSanFranciscoDisplayFont);
expect(textTheme.headline4, isDisplayFont); expect(textTheme.headline4, isSanFranciscoDisplayFont);
expect(textTheme.headline5, isDisplayFont); expect(textTheme.headline5, isSanFranciscoDisplayFont);
expect(textTheme.headline6, isDisplayFont); expect(textTheme.headline6, isSanFranciscoDisplayFont);
expect(textTheme.subtitle1, isTextFont); expect(textTheme.subtitle1, isSanFranciscoTextFont);
expect(textTheme.bodyText1, isTextFont); expect(textTheme.bodyText1, isSanFranciscoTextFont);
expect(textTheme.bodyText2, isTextFont); expect(textTheme.bodyText2, isSanFranciscoTextFont);
expect(textTheme.caption, isTextFont); expect(textTheme.caption, isSanFranciscoTextFont);
expect(textTheme.button, isTextFont); expect(textTheme.button, isSanFranciscoTextFont);
expect(textTheme.subtitle2, isTextFont); expect(textTheme.subtitle2, isSanFranciscoTextFont);
expect(textTheme.overline, isTextFont); expect(textTheme.overline, isSanFranciscoTextFont);
} }
}); });
......
...@@ -357,7 +357,7 @@ void main() { ...@@ -357,7 +357,7 @@ void main() {
expect(semantics, isNot(includesNodeWith(label: 'Dismiss'))); expect(semantics, isNot(includesNodeWith(label: 'Dismiss')));
semantics.dispose(); semantics.dispose();
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android })); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async { testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
......
...@@ -45,6 +45,22 @@ void main() { ...@@ -45,6 +45,22 @@ void main() {
await tester.pump(const Duration(seconds: 5)); await tester.pump(const Duration(seconds: 5));
final double androidResult = getCurrentOffset(); 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 pumpTest(tester, TargetPlatform.iOS);
await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0); await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0);
// Scroll starts ease into the scroll on iOS. // Scroll starts ease into the scroll on iOS.
...@@ -65,6 +81,14 @@ void main() { ...@@ -65,6 +81,14 @@ void main() {
expect(androidResult, lessThan(iOSResult)); // iOS is slipperier than Android expect(androidResult, lessThan(iOSResult)); // iOS is slipperier than Android
expect(androidResult, lessThan(macOSResult)); // macOS 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 { testWidgets('fling and tap to stop', (WidgetTester tester) async {
......
...@@ -642,9 +642,6 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi ...@@ -642,9 +642,6 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
'web': web, 'web': web,
'macos': macos, 'macos': macos,
'year': DateTime.now().year, '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,
}; };
} }
......
{{#includeTargetPlatformWorkaround}}
import 'dart:io';
import 'package:flutter/foundation.dart';
{{/includeTargetPlatformWorkaround}}
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
{{#withDriverTest}} {{#withDriverTest}}
import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_driver/driver_extension.dart';
...@@ -13,39 +8,15 @@ import 'dart:async'; ...@@ -13,39 +8,15 @@ import 'dart:async';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart'; import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart';
{{/withPluginHook}} {{/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() { void main() {
_enablePlatformOverrideForDesktop();
runApp(MyApp());
}
{{/includeTargetPlatformWorkaround}}
{{/withDriverTest}}
{{#withDriverTest}} {{#withDriverTest}}
void main() {
{{#includeTargetPlatformWorkaround}}
_enablePlatformOverrideForDesktop();
{{/includeTargetPlatformWorkaround}}
// Enable integration testing with the Flutter Driver extension. // Enable integration testing with the Flutter Driver extension.
// See https://flutter.dev/testing/ for more info. // See https://flutter.dev/testing/ for more info.
enableFlutterDriverExtension(); enableFlutterDriverExtension();
{{/withDriverTest}}
runApp(MyApp()); runApp(MyApp());
} }
{{/withDriverTest}}
{{^withPluginHook}} {{^withPluginHook}}
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment