Commit 0f68a2ba authored by Adam Barth's avatar Adam Barth Committed by GitHub

Be more explicit about the default TargetPlatform (#5034)

parent e4e6b01a
......@@ -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,
......
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