platform.dart 921 Bytes
Newer Older
1 2 3 4
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8
import 'dart:io' show Platform;

import 'assertions.dart';

9 10 11 12 13 14 15 16
/// The platform that user interaction should adapt to target.
enum TargetPlatform {
  /// Android: <https://www.android.com/>
  android,

  /// iOS: <http://www.apple.com/ios/>
  iOS,
}
17 18 19 20 21 22 23 24 25 26 27 28 29

/// 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.'
  );
}