Unverified Commit 245d1b51 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Add macOS to TargetPlatform (#43457)

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

I haven't updated the tests here, that will come in a follow-up PR.
parent e60c0f68
......@@ -8,13 +8,17 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(),
......
......@@ -108,11 +108,16 @@ class IconSample {
final String description;
}
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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());
}
......@@ -296,13 +296,17 @@ class DragAndDropAppState extends State<DragAndDropApp> {
}
}
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(),
......
......@@ -8,13 +8,17 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(),
......
......@@ -8,13 +8,17 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(),
......
......@@ -7,13 +7,17 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(
......
......@@ -475,13 +475,17 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM
}
}
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(),
));
......
......@@ -206,13 +206,17 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
}
}
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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,
......
......@@ -141,12 +141,17 @@ class PageViewAppState extends State<PageViewApp> {
}
}
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(
......
......@@ -8,13 +8,17 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(
......
......@@ -12,13 +12,17 @@ import 'package:flutter/scheduler.dart';
int seed = 0;
void main() {
if (!kIsWeb && Platform.isMacOS) {
// TODO(gspencergoog): Update this when TargetPlatform includes macOS. https://github.com/flutter/flutter/issues/31366
// See https://github.com/flutter/flutter/wiki/Desktop-shells#target-platform-override
// 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(),
......
......@@ -64,6 +64,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
case TargetPlatform.fuchsia:
return Icons.arrow_back;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return Icons.arrow_back_ios;
}
assert(false);
......
......@@ -360,6 +360,8 @@ class _PlatformItem extends StatelessWidget {
return 'Fuchsia';
case TargetPlatform.iOS:
return 'Cupertino';
case TargetPlatform.macOS:
return 'Material Desktop (macOS)';
}
assert(false);
return null;
......
......@@ -14,8 +14,12 @@ import 'gallery/app.dart';
// Sets a platform override for desktop to avoid exceptions. See
// https://flutter.dev/desktop#target-platform-override for more info.
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
// This is only included in the Gallery because Flutter's testing infrastructure
// uses the Gallery for various tests, and this allows us to test on desktop
// platforms that aren't yet supported in TargetPlatform.
void _enablePlatformOverrideForDesktop() {
if (!kIsWeb && (Platform.isMacOS || Platform.isWindows || Platform.isLinux)) {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
}
......
......@@ -230,6 +230,7 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.macOS:
hasSuitableHapticHardware = false;
break;
}
......
......@@ -445,8 +445,9 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox {
case TargetPlatform.iOS:
HapticFeedback.lightImpact();
break;
case TargetPlatform.fuchsia:
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.macOS:
break;
}
}
......
......@@ -11,6 +11,8 @@ 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) {
result = platform.TargetPlatform.android;
} else if (Platform.isFuchsia) {
......
......@@ -163,6 +163,9 @@ abstract class BindingBase {
case 'iOS':
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
break;
case 'macOS':
debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
break;
case 'fuchsia':
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
break;
......
......@@ -47,6 +47,9 @@ enum TargetPlatform {
/// iOS: <http://www.apple.com/ios/>
iOS,
/// macOS: <http://www.apple.com/macos>
macOS,
}
/// Override the [defaultTargetPlatform].
......
......@@ -481,6 +481,7 @@ class _MaterialScrollBehavior extends ScrollBehavior {
// the base class as well.
switch (getPlatform(context)) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return child;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
......
......@@ -393,6 +393,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget {
case TargetPlatform.fuchsia:
return false;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return actions == null || actions.length < 2;
}
return null;
......@@ -483,6 +484,7 @@ class _AppBarState extends State<AppBar> {
namesRoute = true;
break;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
break;
}
title = DefaultTextStyle(
......
......@@ -34,6 +34,7 @@ class BackButtonIcon extends StatelessWidget {
case TargetPlatform.fuchsia:
return Icons.arrow_back;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return Icons.arrow_back_ios;
}
assert(false);
......
......@@ -283,6 +283,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
String _getRouteLabel(MaterialLocalizations localizations) {
switch (Theme.of(context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return '';
case TargetPlatform.android:
case TargetPlatform.fuchsia:
......
......@@ -911,6 +911,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
HapticFeedback.vibrate();
break;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
break;
}
}
......
......@@ -314,6 +314,7 @@ class AlertDialog extends StatelessWidget {
if (title == null) {
switch (theme.platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
label = semanticLabel;
break;
case TargetPlatform.android:
......@@ -591,6 +592,7 @@ class SimpleDialog extends StatelessWidget {
String label = semanticLabel;
if (title == null) {
switch (theme.platform) {
case TargetPlatform.macOS:
case TargetPlatform.iOS:
label = semanticLabel;
break;
......
......@@ -177,6 +177,7 @@ class Drawer extends StatelessWidget {
String label = semanticLabel;
switch (Theme.of(context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
label = semanticLabel;
break;
case TargetPlatform.android:
......@@ -523,6 +524,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
platformHasBackButton = true;
break;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
case TargetPlatform.fuchsia:
platformHasBackButton = false;
break;
......
......@@ -166,7 +166,7 @@ class FlexibleSpaceBar extends StatefulWidget {
/// Whether the title should be centered.
///
/// By default this property is true if the current target platform
/// is [TargetPlatform.iOS], false otherwise.
/// is [TargetPlatform.iOS] or [TargetPlatform.macOS], false otherwise.
final bool centerTitle;
/// Collapse effect while scrolling.
......@@ -239,6 +239,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
case TargetPlatform.fuchsia:
return false;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return true;
}
return null;
......@@ -341,6 +342,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
Widget title;
switch (theme.platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
title = widget.title;
break;
case TargetPlatform.fuchsia:
......@@ -349,6 +351,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
namesRoute: true,
child: widget.title,
);
break;
}
// StretchMode.fadeTitle
......
......@@ -486,14 +486,15 @@ class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder {
class PageTransitionsTheme extends Diagnosticable {
/// Construct a PageTransitionsTheme.
///
/// By default the list of builders is: [FadeUpwardsPageTransitionsBuilder],
/// [CupertinoPageTransitionsBuilder] for [TargetPlatform.android]
/// and [TargetPlatform.iOS] respectively.
/// By default the list of builders is: [FadeUpwardsPageTransitionsBuilder]
/// for [TargetPlatform.android], and [CupertinoPageTransitionsBuilder] for
/// [TargetPlatform.iOS] and [TargetPlatform.macOS].
const PageTransitionsTheme({ Map<TargetPlatform, PageTransitionsBuilder> builders }) : _builders = builders;
static const Map<TargetPlatform, PageTransitionsBuilder> _defaultBuilders = <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
};
/// The [PageTransitionsBuilder]s supported by this theme.
......
......@@ -830,6 +830,7 @@ Future<T> showMenu<T>({
String label = semanticLabel;
switch (Theme.of(context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
label = semanticLabel;
break;
case TargetPlatform.android:
......@@ -1083,6 +1084,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
case TargetPlatform.fuchsia:
return const Icon(Icons.more_vert);
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return const Icon(Icons.more_horiz);
}
return null;
......
......@@ -2299,6 +2299,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
switch (themeData.platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
_addIfNonNull(
children,
GestureDetector(
......
......@@ -86,6 +86,7 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin {
final ThemeData theme = Theme.of(context);
switch (theme.platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
// On iOS, stop all local animations. CupertinoScrollbar has its own
// animations.
_fadeoutTimer?.cancel();
......
......@@ -487,6 +487,7 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
String routeName;
switch (theme.platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
routeName = '';
break;
case TargetPlatform.android:
......
......@@ -70,6 +70,7 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
if (delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
renderEditable.selectPositionAt(
from: details.globalPosition,
cause: SelectionChangedCause.longPress,
......@@ -93,6 +94,7 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
if (delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
break;
case TargetPlatform.android:
......@@ -110,6 +112,7 @@ class _SelectableTextSelectionGestureDetectorBuilder extends TextSelectionGestur
if (delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
renderEditable.selectPositionAt(
from: details.globalPosition,
cause: SelectionChangedCause.longPress,
......@@ -462,6 +465,7 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
switch (Theme.of(context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
if (cause == SelectionChangedCause.longPress) {
_editableText?.bringIntoView(selection.base);
}
......@@ -529,6 +533,7 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
switch (themeData.platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
forcePressEnabled = true;
textSelectionControls = cupertinoTextSelectionControls;
paintCursorAboveText = true;
......
......@@ -502,6 +502,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
case TargetPlatform.fuchsia:
return _buildMaterialSlider(context);
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return _buildCupertinoSlider(context);
}
}
......@@ -888,14 +889,15 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
double get _adjustmentUnit {
switch (_platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
// Matches iOS implementation of material slider.
return 0.1;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
default:
// Matches Android implementation of material slider.
return 0.05;
}
return 0.0;
}
void _updateLabelPainter() {
......
......@@ -354,6 +354,7 @@ class _SwitchState extends State<Switch> with TickerProviderStateMixin {
case TargetPlatform.fuchsia:
return buildMaterialSwitch(context);
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return buildCupertinoSwitch(context);
}
}
......
......@@ -59,6 +59,7 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
if (delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
renderEditable.selectPositionAt(
from: details.globalPosition,
cause: SelectionChangedCause.longPress,
......@@ -82,6 +83,7 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
if (delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
break;
case TargetPlatform.android:
......@@ -100,6 +102,7 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
if (delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
renderEditable.selectPositionAt(
from: details.globalPosition,
cause: SelectionChangedCause.longPress,
......@@ -868,6 +871,7 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe
switch (Theme.of(context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
if (cause == SelectionChangedCause.longPress) {
_editableText?.bringIntoView(selection.base);
}
......@@ -923,6 +927,7 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe
switch (themeData.platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
forcePressEnabled = true;
textSelectionControls = cupertinoTextSelectionControls;
paintCursorAboveText = true;
......
......@@ -873,9 +873,10 @@ class ThemeData extends Diagnosticable {
/// In a test environment, the platform returned is [TargetPlatform.android]
/// regardless of the host platform. (Android was chosen because the tests
/// were originally written assuming Android-like behavior, and we added
/// platform adaptations for iOS later). Tests can check iOS behavior by
/// setting the [platform] of the [Theme] explicitly to [TargetPlatform.iOS],
/// or by setting [debugDefaultTargetPlatformOverride].
/// platform adaptations for other platforms later). Tests can check behavior
/// for other platforms by setting the [platform] of the [Theme] explicitly to
/// another [TargetPlatform] value, or by setting
/// [debugDefaultTargetPlatformOverride].
final TargetPlatform platform;
/// Configures the hit test size of certain Material widgets.
......
......@@ -209,6 +209,7 @@ class _DayPeriodControl extends StatelessWidget {
_announceToAccessibility(context, MaterialLocalizations.of(context).anteMeridiemAbbreviation);
break;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
break;
}
_togglePeriod();
......@@ -224,6 +225,7 @@ class _DayPeriodControl extends StatelessWidget {
_announceToAccessibility(context, MaterialLocalizations.of(context).postMeridiemAbbreviation);
break;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
break;
}
_togglePeriod();
......@@ -1525,6 +1527,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
});
break;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
break;
}
}
......
......@@ -88,10 +88,11 @@ enum ScriptCategory {
class Typography extends Diagnosticable {
/// Creates a typography instance.
///
/// If [platform] is [TargetPlatform.iOS], the default values for [black] and
/// [white] are [blackCupertino] and [whiteCupertino] respectively. Otherwise
/// they are [blackMountainView] and [whiteMoutainView]. If [platform] is
/// null then both [black] and [white] must be specified.
/// If [platform] is [TargetPlatform.iOS] or [TargetPlatform.macOS], the
/// default values for [black] and [white] are [blackCupertino] and
/// [whiteCupertino] respectively. Otherwise they are [blackMountainView] and
/// [whiteMoutainView]. If [platform] is null then both [black] and [white]
/// must be specified.
///
/// The default values for [englishLike], [dense], and [tall] are
/// [englishLike2014], [dense2014], and [tall2014].
......@@ -106,6 +107,7 @@ class Typography extends Diagnosticable {
assert(platform != null || (black != null && white != null));
switch (platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
black ??= blackCupertino;
white ??= whiteCupertino;
break;
......
......@@ -1719,6 +1719,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
assert(defaultTargetPlatform != null);
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight + 2);
case TargetPlatform.android:
case TargetPlatform.fuchsia:
......@@ -1777,6 +1778,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
if (caretHeight != null) {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
final double heightDiff = caretHeight - caretRect.height;
// Center the caret vertically along the text.
caretRect = Rect.fromLTWH(
......
......@@ -253,8 +253,9 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
case TargetPlatform.android:
lowerOverlayStyle = layer.find<SystemUiOverlayStyle>(bottom);
break;
case TargetPlatform.iOS:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:
case TargetPlatform.macOS:
break;
}
// If there are no overlay styles in the UI don't bother updating.
......
......@@ -82,6 +82,7 @@ class ModalBarrier extends StatelessWidget {
platformSupportsDismissingBarrier = false;
break;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
platformSupportsDismissingBarrier = true;
break;
}
......
......@@ -1217,9 +1217,10 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
/// True if one or more [WillPopCallback] callbacks exist.
///
/// This method is used to disable the horizontal swipe pop gesture
/// supported by [MaterialPageRoute] for [TargetPlatform.iOS].
/// If a pop might be vetoed, then the back gesture is disabled.
/// This method is used to disable the horizontal swipe pop gesture supported
/// by [MaterialPageRoute] for [TargetPlatform.iOS] and
/// [TargetPlatform.macOS]. If a pop might be vetoed, then the back gesture is
/// disabled.
///
/// The [buildTransitions] method will not be called again if this changes,
/// since it can change during the build as descendants of the route add or
......
......@@ -35,6 +35,7 @@ class ScrollBehavior {
// _MaterialScrollBehavior as well.
switch (getPlatform(context)) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return child;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
......@@ -54,6 +55,7 @@ class ScrollBehavior {
ScrollPhysics getScrollPhysics(BuildContext context) {
switch (getPlatform(context)) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return const BouncingScrollPhysics();
case TargetPlatform.android:
case TargetPlatform.fuchsia:
......
......@@ -331,6 +331,7 @@ void main() {
final Finder button = find.byType(RaisedButton);
expect(tester.getBottomLeft(button).dy, equals(550.0));
expect(tester.getCenter(button).dx, equals(400.0));
debugDefaultTargetPlatformOverride = null;
// Drag for overscroll
await tester.drag(find.byType(Scrollable), const Offset(0.0, -50.0));
......
......@@ -656,7 +656,8 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
// removed, and the new schema should always be used.
'useNewPluginSchema': macos,
// If a desktop platform is included, add a workaround for #31366.
'includeTargetPlatformWorkaround': macos,
// When Linux and Windows are added, we will need this workaround again.
'includeTargetPlatformWorkaround': false,
};
}
......
......@@ -18,7 +18,7 @@ import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart';
// 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.isMacOS || Platform.isWindows || Platform.isLinux)) {
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
}
}
......
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