diff --git a/packages/flutter/lib/src/foundation/platform.dart b/packages/flutter/lib/src/foundation/platform.dart
index 01bd4892e07..3881055e19e 100644
--- a/packages/flutter/lib/src/foundation/platform.dart
+++ b/packages/flutter/lib/src/foundation/platform.dart
@@ -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:
@@ -10,3 +14,16 @@ enum TargetPlatform {
/// 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.'
+ );
+}
diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart
index 78241fba95a..3a9efc3bc7a 100644
--- a/packages/flutter/lib/src/material/theme_data.dart
+++ b/packages/flutter/lib/src/material/theme_data.dart
@@ -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,