Skip to content

Commit 1ba4f1f

Browse files
authored
Add Linux and Windows target platforms (flutter#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 flutter#31366
1 parent 7f6f08a commit 1ba4f1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+365
-246
lines changed

dev/integration_tests/flutter_driver_screenshot_test/lib/main.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ class _MyHomePageState extends State<_MyHomePage> {
8383
return (await deviceInfo.androidInfo).model;
8484
case TargetPlatform.fuchsia:
8585
return 'fuchsia';
86-
default:
86+
case TargetPlatform.macOS:
87+
case TargetPlatform.linux:
88+
case TargetPlatform.windows:
8789
return 'unsupported';
90+
break;
8891
}
89-
break;
92+
assert(false, 'Unhandled Theme target platform ${Theme.of(context).platform}.');
93+
return 'unsupported';
9094
}
9195
return 'unknown message: "$message"';
9296
}

dev/manual_tests/lib/actions.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:io';
6-
75
import 'package:flutter/foundation.dart';
86
import 'package:flutter/material.dart';
97
import 'package:flutter/services.dart';
108
import 'package:flutter/widgets.dart';
119

12-
// Sets a platform override for desktop to avoid exceptions. See
13-
// https://flutter.dev/desktop#target-platform-override for more info.
14-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
15-
void _enablePlatformOverrideForDesktop() {
16-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
17-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
18-
}
19-
}
20-
2110
void main() {
22-
_enablePlatformOverrideForDesktop();
2311
runApp(const MaterialApp(
2412
title: 'Actions Demo',
2513
home: FocusDemo(),

dev/manual_tests/lib/animated_icons.dart

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:io';
6-
7-
import 'package:flutter/foundation.dart';
85
import 'package:flutter/material.dart';
96

107
class AnimatedIconsTestApp extends StatelessWidget {
@@ -108,16 +105,4 @@ class IconSample {
108105
final String description;
109106
}
110107

111-
// Sets a platform override for desktop to avoid exceptions. See
112-
// https://flutter.dev/desktop#target-platform-override for more info.
113-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
114-
void _enablePlatformOverrideForDesktop() {
115-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
116-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
117-
}
118-
}
119-
120-
void main() {
121-
_enablePlatformOverrideForDesktop();
122-
runApp(AnimatedIconsTestApp());
123-
}
108+
void main() => runApp(AnimatedIconsTestApp());

dev/manual_tests/lib/density.dart

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:io';
76

87
import 'package:flutter/foundation.dart';
98
import 'package:flutter/scheduler.dart' show timeDilation;
@@ -24,19 +23,7 @@ final Map<int, Color> m2SwatchColors = <int, Color>{
2423
};
2524
final MaterialColor m2Swatch = MaterialColor(m2SwatchColors[500].value, m2SwatchColors);
2625

27-
// Sets a platform override for desktop to avoid exceptions. See
28-
// https://flutter.dev/desktop#target-platform-override for more info.
29-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
30-
void _enablePlatformOverrideForDesktop() {
31-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
32-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
33-
}
34-
}
35-
36-
void main() {
37-
_enablePlatformOverrideForDesktop();
38-
runApp(MyApp());
39-
}
26+
void main() => runApp(MyApp());
4027

4128
class MyApp extends StatelessWidget {
4229
static const String _title = 'Density Test';

dev/manual_tests/lib/drag_and_drop.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:io';
65
import 'dart:math' as math;
76

87
import 'package:flutter/foundation.dart';
@@ -296,17 +295,7 @@ class DragAndDropAppState extends State<DragAndDropApp> {
296295
}
297296
}
298297

299-
// Sets a platform override for desktop to avoid exceptions. See
300-
// https://flutter.dev/desktop#target-platform-override for more info.
301-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
302-
void _enablePlatformOverrideForDesktop() {
303-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
304-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
305-
}
306-
}
307-
308298
void main() {
309-
_enablePlatformOverrideForDesktop();
310299
runApp(MaterialApp(
311300
title: 'Drag and Drop Flutter Demo',
312301
home: DragAndDropApp(),

dev/manual_tests/lib/focus.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:io';
6-
75
import 'package:flutter/foundation.dart';
86
import 'package:flutter/material.dart';
97
import 'package:flutter/services.dart';
108
import 'package:flutter/widgets.dart';
119

12-
// Sets a platform override for desktop to avoid exceptions. See
13-
// https://flutter.dev/desktop#target-platform-override for more info.
14-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
15-
void _enablePlatformOverrideForDesktop() {
16-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
17-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
18-
}
19-
}
20-
2110
void main() {
22-
_enablePlatformOverrideForDesktop();
2311
runApp(const MaterialApp(
2412
title: 'Focus Demo',
2513
home: FocusDemo(),

dev/manual_tests/lib/hover.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:io';
6-
75
import 'package:flutter/foundation.dart';
86
import 'package:flutter/material.dart';
97
import 'package:flutter/widgets.dart';
108

11-
// Sets a platform override for desktop to avoid exceptions. See
12-
// https://flutter.dev/desktop#target-platform-override for more info.
13-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
14-
void _enablePlatformOverrideForDesktop() {
15-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
16-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
17-
}
18-
}
19-
209
void main() {
21-
_enablePlatformOverrideForDesktop();
2210
runApp(const MaterialApp(
2311
title: 'Hover Demo',
2412
home: HoverDemo(),

dev/manual_tests/lib/main.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:io';
6-
7-
import 'package:flutter/foundation.dart';
85
import 'package:flutter/widgets.dart';
96

10-
// Sets a platform override for desktop to avoid exceptions. See
11-
// https://flutter.dev/desktop#target-platform-override for more info.
12-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
13-
void _enablePlatformOverrideForDesktop() {
14-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
15-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
16-
}
17-
}
18-
197
void main() {
20-
_enablePlatformOverrideForDesktop();
218
runApp(const Directionality(
229
textDirection: TextDirection.ltr,
2310
child: Center(

dev/manual_tests/lib/material_arc.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:io';
76

87
import 'package:flutter/foundation.dart';
98
import 'package:flutter/gestures.dart';
@@ -475,17 +474,7 @@ class _AnimationDemoState extends State<AnimationDemo> with TickerProviderStateM
475474
}
476475
}
477476

478-
// Sets a platform override for desktop to avoid exceptions. See
479-
// https://flutter.dev/desktop#target-platform-override for more info.
480-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
481-
void _enablePlatformOverrideForDesktop() {
482-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
483-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
484-
}
485-
}
486-
487477
void main() {
488-
_enablePlatformOverrideForDesktop();
489478
runApp(const MaterialApp(
490479
home: AnimationDemo(),
491480
));

dev/manual_tests/lib/overlay_geometry.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:io';
6-
75
import 'package:flutter/foundation.dart';
86
import 'package:flutter/gestures.dart';
97
import 'package:flutter/material.dart';
@@ -206,17 +204,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
206204
}
207205
}
208206

209-
// Sets a platform override for desktop to avoid exceptions. See
210-
// https://flutter.dev/desktop#target-platform-override for more info.
211-
// TODO(gspencergoog): Remove once TargetPlatform includes all desktop platforms.
212-
void _enablePlatformOverrideForDesktop() {
213-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
214-
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
215-
}
216-
}
217-
218207
void main() {
219-
_enablePlatformOverrideForDesktop();
220208
runApp(MaterialApp(
221209
theme: ThemeData(
222210
brightness: Brightness.light,

0 commit comments

Comments
 (0)