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> {
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"';
}
......
......@@ -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(),
......
......@@ -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());
......@@ -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<int, Color> m2SwatchColors = <int, Color>{
};
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';
......
......@@ -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<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() {
_enablePlatformOverrideForDesktop();
runApp(MaterialApp(
title: 'Drag and Drop Flutter Demo',
home: DragAndDropApp(),
......
......@@ -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(),
......
......@@ -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(),
......
......@@ -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(
......
......@@ -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<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() {
_enablePlatformOverrideForDesktop();
runApp(const MaterialApp(
home: AnimationDemo(),
));
......
......@@ -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<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() {
_enablePlatformOverrideForDesktop();
runApp(MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
......
......@@ -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<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() {
_enablePlatformOverrideForDesktop();
runApp(MaterialApp(
title: 'PageView',
theme: ThemeData(
......
......@@ -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(
......
......@@ -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(),
......
......@@ -62,6 +62,8 @@ class _DrawerDemoState extends State<DrawerDemo> 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:
......
......@@ -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;
......
......@@ -234,7 +234,9 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
hasSuitableHapticHardware = false;
break;
}
......
......@@ -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;
}
}
......
......@@ -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'))
......
......@@ -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:
......
......@@ -45,11 +45,17 @@ enum TargetPlatform {
/// Fuchsia: <https://fuchsia.googlesource.com/>
fuchsia,
/// iOS: <http://www.apple.com/ios/>
/// iOS: <https://www.apple.com/ios/>
iOS,
/// macOS: <http://www.apple.com/macos>
/// Linux: <https://www.linux.org>
linux,
/// macOS: <https://www.apple.com/macos>
macOS,
/// Windows: <https://www.windows.com>
windows,
}
/// Override the [defaultTargetPlatform].
......
......@@ -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:
......
......@@ -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<AppBar> {
switch (theme.platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
namesRoute = true;
break;
case TargetPlatform.iOS:
......
......@@ -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:
......
......@@ -339,6 +339,8 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
return '';
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return localizations.dialogLabel;
}
return null;
......
......@@ -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:
......
......@@ -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;
}
}
......
......@@ -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<DrawerController> with SingleTickerPro
case TargetPlatform.iOS:
case TargetPlatform.macOS:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
platformHasBackButton = false;
break;
}
......
......@@ -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<void>.value();
break;
}
assert(false, 'Unhandled TargetPlatform ${_platform(context)}');
return Future<void>.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<void>.value();
break;
}
assert(false, 'Unhandled TargetPlatform ${_platform(context)}');
return Future<void>.value();
}
/// Wraps a [GestureLongPressCallback] to provide platform specific feedback
......
......@@ -237,6 +237,8 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
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<FlexibleSpaceBar> {
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,
......
......@@ -494,7 +494,9 @@ class PageTransitionsTheme extends Diagnosticable {
static const Map<TargetPlatform, PageTransitionsBuilder> _defaultBuilders = <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.linux: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(),
};
/// The [PageTransitionsBuilder]s supported by this theme.
......
......@@ -837,6 +837,8 @@ Future<T> showMenu<T>({
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<T> extends State<PopupMenuButton<T>> {
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:
......
......@@ -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() {
......
......@@ -2498,6 +2498,8 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
break;
}
......
......@@ -96,6 +96,8 @@ class _ScrollbarState extends State<Scrollbar> 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();
......
......@@ -492,6 +492,8 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
routeName = searchFieldLabel;
}
......
......@@ -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<SelectableText> 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<SelectableText> with AutomaticKeepAlive
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
forcePressEnabled = false;
textSelectionControls = materialTextSelectionControls;
paintCursorAboveText = false;
......
......@@ -502,6 +502,8 @@ class _SliderState extends State<Slider> 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;
}
......
......@@ -352,6 +352,8 @@ class _SwitchState extends State<Switch> 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:
......
......@@ -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<TextField> 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<TextField> implements TextSelectionGestureDe
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
forcePressEnabled = false;
textSelectionControls = materialTextSelectionControls;
paintCursorAboveText = false;
......
......@@ -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();
......
......@@ -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.
......
......@@ -255,7 +255,9 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
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.
......
......@@ -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;
......
......@@ -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:
......
......@@ -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;
......
......@@ -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', <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'}));
expect(result, <String, String>{'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');
......
......@@ -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 {
......
......@@ -47,7 +47,7 @@ void main() {
expect(topBeforeScroll.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 {
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>{ 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>{ 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 {
......
......@@ -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);
}
......
......@@ -1250,7 +1250,7 @@ void main() {
));
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 {
final SemanticsTester semantics = SemanticsTester(tester);
......@@ -1497,7 +1497,7 @@ void main() {
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;
await tester.pumpWidget(buildFrame(platform));
await tester.pumpAndSettle(); // Finish the theme change animation.
......
......@@ -96,7 +96,7 @@ void main() {
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;
await tester.pumpWidget(buildFrame(platform));
await tester.pumpAndSettle(); // Finish the theme change animation.
......
......@@ -623,7 +623,7 @@ void main() {
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;
await tester.pumpWidget(buildFrame(platform));
await tester.pumpAndSettle(); // Finish the theme change animation.
......
......@@ -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>{ 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 {
EditableText.debugDeterministicCursor = true;
......@@ -1125,7 +1125,7 @@ void main() {
matching: find.byType(Container),
));
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 {
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>{ TargetPlatform.android, TargetPlatform.fuchsia }));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ 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>{ TargetPlatform.android, TargetPlatform.fuchsia }));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ 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>{ TargetPlatform.android, TargetPlatform.fuchsia }));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ 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>{ TargetPlatform.android, TargetPlatform.fuchsia }));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ 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>{ TargetPlatform.android, TargetPlatform.fuchsia }));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets('force press selects word', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(
......
......@@ -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, <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/
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 <TextTheme>[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 <TextTheme>[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);
}
});
......
......@@ -357,7 +357,7 @@ void main() {
expect(semantics, isNot(includesNodeWith(label: 'Dismiss')));
semantics.dispose();
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android }));
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
......
......@@ -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 {
......
......@@ -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,
};
}
......
{{#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 {
......
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