| // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| /// All non-test classes and interfaces exposed by the package. |
| /// |
| /// All classes are declared in the same library, so that they can all be final, |
| /// and still depend with the. |
| /// @docImport 'platforms_impl.dart'; |
| // ignore: unnecessary_library_name - Used by DartDoc |
| library exported_platforms; |
| |
| import 'platforms_impl.dart' show Platform; |
| export 'platforms_impl.dart' show BrowserPlatform, NativePlatform, Platform; |
| |
| /// Shorthands for checking operating system on the native platform. |
| /// |
| /// Extension getters on `Platform` which forward to the operating system |
| /// checks on [Platform.nativePlatform], after checking that this is a native |
| /// platform. |
| extension PlatformIsOS on Platform { |
| /// Whether this is a [nativePlatform] with [NativePlatform.isAndroid]. |
| @pragma('vm:prefer-inline') |
| @pragma('dart2js:prefer-inline') |
| bool get isAndroid => nativePlatform?.isAndroid ?? false; |
| |
| /// Whether this is a [nativePlatform] with [NativePlatform.isFuchsia]. |
| @pragma('vm:prefer-inline') |
| @pragma('dart2js:prefer-inline') |
| bool get isFuchsia => nativePlatform?.isFuchsia ?? false; |
| |
| /// Whether this is a [nativePlatform] with [NativePlatform.isIOS]. |
| @pragma('vm:prefer-inline') |
| @pragma('dart2js:prefer-inline') |
| bool get isIOS => nativePlatform?.isIOS ?? false; |
| |
| /// Whether this is a [nativePlatform] with [NativePlatform.isLinux]. |
| @pragma('vm:prefer-inline') |
| @pragma('dart2js:prefer-inline') |
| bool get isLinux => nativePlatform?.isLinux ?? false; |
| |
| /// Whether this is a [nativePlatform] with [NativePlatform.isMacOS]. |
| @pragma('vm:prefer-inline') |
| @pragma('dart2js:prefer-inline') |
| bool get isMacOS => nativePlatform?.isMacOS ?? false; |
| |
| /// Whether this is a [nativePlatform] with [NativePlatform.isWindows]. |
| @pragma('vm:prefer-inline') |
| @pragma('dart2js:prefer-inline') |
| bool get isWindows => nativePlatform?.isWindows ?? false; |
| } |