mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Be more explicit about the default TargetPlatform (#5034)
This commit is contained in:
parent
e4e6b01afa
commit
0f68a2bac2
@ -2,6 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'assertions.dart';
|
||||
|
||||
/// The platform that user interaction should adapt to target.
|
||||
enum TargetPlatform {
|
||||
/// Android: <https://www.android.com/>
|
||||
@ -10,3 +14,16 @@ enum TargetPlatform {
|
||||
/// iOS: <http://www.apple.com/ios/>
|
||||
iOS,
|
||||
}
|
||||
|
||||
/// The [TargetPlatform] that matches the platform on which the framework is currently executing.
|
||||
TargetPlatform get defaultTargetPlatform {
|
||||
if (Platform.isIOS || Platform.isMacOS)
|
||||
return TargetPlatform.iOS;
|
||||
if (Platform.isAndroid || Platform.isLinux)
|
||||
return TargetPlatform.android;
|
||||
throw new FlutterError(
|
||||
'Unknown platform\n'
|
||||
'${Platform.operatingSystem} was not recognized as a target platform. '
|
||||
'Consider updating the list of TargetPlatforms to include this platform.'
|
||||
);
|
||||
}
|
||||
|
@ -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' show Platform;
|
||||
import 'dart:ui' show Color, hashValues;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
@ -125,7 +124,7 @@ class ThemeData {
|
||||
primaryTextTheme ??= primaryIsDark ? Typography.white : Typography.black;
|
||||
iconTheme ??= isDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black);
|
||||
primaryIconTheme ??= primaryIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black);
|
||||
platform ??= (Platform.isIOS || Platform.isMacOS) ? TargetPlatform.iOS : TargetPlatform.android;
|
||||
platform ??= defaultTargetPlatform;
|
||||
return new ThemeData.raw(
|
||||
brightness: brightness,
|
||||
primaryColor: primaryColor,
|
||||
|
Loading…
Reference in New Issue
Block a user