pub repository
mirror.p-hatan.complatform
3.2.0A pluggable, mockable platform information abstraction for Dart.
Cached in Iran · Upstream SHA-256 matched
Readme
A generic platform abstraction for Dart.
Cross-platform platform API
Provides access to platform specific information of the current runtime platform through a cross-platform API.
On a native platform, the NativePlatform class in this package provides a
lightweight wrapper around the static Platform properties of dart:io,
with the same rich, Dart-idiomatic API for querying the current runtime.
On the web, there is no NativePlatform object, and cross-platform client code
can avoid dependencies on such properties simply by checking if
Platform.current.nativePlatform is null.
Instead web code has a Platform.current.browserPlatform values that is
a non-null BrowserPlatform.
Example:
import 'package:platform/platform.dart';
void main() {
switch (Platform.current) {
case Platform(:var nativePlatform?):
// `nativePlatform` has `dart:io`'s `Platform` properties.
print(
'Running on ${nativePlatform.operatingSystem} v.'
'${nativePlatform.operatingSystemVersion}',
);
case Platform(:var browserPlatform?):
// `browserPlatform` has version information from `windows.userAgent`.
print('Running on ${browserPlatform.userAgent}');
}
}
Code size
Using platform-specific properties like Platform.isLinux as branch conditions
will allow a production compiler to completely omit the branch
that it knows it's not currently compiling for.
Testing and Mocking
In tests, the package:platform/testing.dart library provides ways to mock
platform objects with custom tailored configurations,
and allows Zone based overriding of the Platform.current value.
[!NOTE] The testing library should only be used in tests, since its mere presence may affect how much code a compiled program will retain.
Changelog
3.2.0
-
New non-backwards compatible API. Use
Platform.currentto access the current platform, andPlatform.current.nativePlatformto either get access to native platform information, or get anullon non-native platforms. SimilarlyPlatform.current.browserPlatformis only non-nullon the web.Mocking APIs are moved to a separate library to ensure they are only used for testing, and to allow better performance in production.
Legacy APIs are deprecated, but retained and emulated using the new API. Use
dart fixto migrate off the deprecated API.
3.1.6
- Move to
dart-lang/coremonorepo.
3.1.5
- Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.
- Transfers the package source from https://github.com/flutter/packages to https://github.com/dart-lang/platform.
3.1.4
- Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
- Fixes new lint warnings.
3.1.3
- Adds example app.
3.1.2
- Adds pub topics to package metadata.
- Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.
3.1.1
- Transfers the package source from https://github.com/google/platform.dart to https://github.com/flutter/packages.
3.1.0
- Removed
Platform.packageRoot, which was already marked deprecated, and which didn't work in Dart 2.
3.0.2
- Added
FakePlatform.copyWithfunction.
3.0.1
- Added string constants for each of the supported platforms for use in switch statements.
3.0.0
- First stable null safe release.
3.0.0-nullsafety.4
- Update supported SDK range.
3.0.0-nullsafety.3
- Update supported SDK range.
3.0.0-nullsafety.2
- Update supported SDK range.
3.0.0-nullsafety.1
- Migrate package to null-safe dart.
2.2.1
- Add
operatingSystemVersion
2.2.0
- Declare compatibility with Dart 2 stable
- Update dependency on
package:testto 1.0
2.1.2
- Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use.
2.1.1
- Bumped maximum Dart SDK version to 2.0.0-dev.infinity
2.1.0
- Added
localeName - Bumped minimum Dart SDK version to 1.24.0-dev.0.0
2.0.0
- Added
stdinSupportsAnsiandstdinSupportsAnsi - Removed
ansiSupported
1.1.1
- Updated
LocalPlatformto use newdart.ioAPI for ansi color support queries - Bumped minimum Dart SDK version to 1.23.0-dev.10.0
1.1.0
- Added
ansiSupported - Bumped minimum Dart SDK version to 1.23.0-dev.9.0
1.0.2
- Minor doc updates
1.0.1
- Added const constructors for
PlatformandLocalPlatform
1.0.0
- Initial version
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add platformpubspec.yaml
name: platform
description: A pluggable, mockable platform information abstraction for Dart.
repository: https://github.com/dart-lang/core/tree/main/pkgs/platform
issue_tracker: https://github.com/dart-lang/core/issues
version: 3.2.0
environment:
# IF UPDATED: Also update SDK version in pubspecs in `example/` and `out/`.
sdk: ^3.10.0
dependencies:
meta: ^1.18.0
dev_dependencies:
dart_flutter_team_lints: ^3.5.2
path: ^1.9.1
test: ^1.29.0
topics:
- information
- platform
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 1.0.0 | 2017-01-25T20:25:16.190Z | Cached | 006287698ad85b5a624136239f5f54d68038ba8fa7dd27511efc281257be5428 |
| 1.0.1 | 2017-01-25T21:45:15.112Z | Cached | acd56d150362e22485d08ef29428c01129aa890e9330d282bd934e64dda1f304 |
| 1.0.2 | 2017-02-13T18:45:49.417Z | Cached | 632db12927a94b7dd902457d1c8513372db97ca9d5dc8cfa9a94b7703c834563 |
| 1.1.0 | 2017-03-16T23:34:57.669Z | Cached | 498a07d39b5a43c7201333631f20287130424c733c3ff01e88a72db0eadfa761 |
| 1.1.1 | 2017-03-28T21:24:49.422740Z | Cached | 7b3cdde106de8ebf252e9df022a1332bca44159fcf98ea604b264d978b753181 |
| 2.0.0 | 2017-04-05T21:30:18.567199Z | Cached | 644b8a034cadf8cefccda87261c84126bde38d88330bbf98e6c2bcb5dcd209f5 |
| 2.1.0 | 2017-05-19T16:23:23.730427Z | Cached | 02a838c23e46dad51cc3b1c99a2010443976771b5e62ae368400bcb24a14dcd1 |
| 2.1.1 | 2017-07-13T18:35:38.355065Z | Cached | b83564875c402d68ff08fd928965b40f86072a7cf265dab3f36785c0cf253abd |
| 2.1.2 | 2018-02-12T18:37:53.523631Z | Cached | 9407299b24973da333ef09f0c2b8fe7e69dadea609a04767ac34eb9e9c29b807 |
| 2.2.0 | 2018-08-13T18:06:22.704670Z | Cached | 02f0d0a773d3911de89cf764067dc8609444890795b92f6b4fdc8098f260157c |
| 2.2.1 | 2019-07-29T02:17:26.407407Z | Cached | 2d03e4330ae22fc7fc0dd38c1fc6d0a9dc7ff10d7deea6dbb2583f7e5c053453 |
| 3.0.0-nullsafety.1 | 2020-08-10T23:57:46.803106Z | Cached | 90cf39685bcb3ce2ad4d1774522d4532869de69e85191bee8c9f44e1f710f7d0 |
| 3.0.0-nullsafety.2 | 2020-09-22T20:43:12.031743Z | Cached | 388a484c298dc3dd52a09de759902e18da77a2c96309006b32ff1e47356f2be9 |
| 3.0.0-nullsafety.3 | 2020-10-22T17:06:57.682021Z | Cached | 6dcfb8c1c784629592ec6b081de6d490f97640c941287e77bcaa1e3103b55105 |
| 3.0.0-nullsafety.4 | 2020-11-04T18:29:51.816242Z | Cached | e4740b21ec2d819d4e157c9b932984d0ca6bd08d83a0c25f9f27818f4d6d9116 |
| 3.0.0 | 2021-02-03T17:44:42.375849Z | Cached | ebc79f16b5f6b609aad4a5e63447d4795d16f7adee46e93ed03200848c006735 |
| 3.0.2 | 2021-08-17T01:11:21.745994Z | Cached | 4a8c298d9ac37f18a1116f7be2aa86c3eaea5913586c5afbb905429dd79efa84 |
| 3.1.0 | 2021-12-02T18:13:18.204487Z | Cached | 4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76 |
| 3.1.1 | 2023-08-16T17:48:59.600563Z | Cached | 57c07bf82207aee366dfaa3867b3164e4f03a238a461a11b0e8a3a510d51203d |
| 3.1.2 | 2023-08-30T15:06:13.346585Z | Cached | ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102 |
| 3.1.3 | 2023-10-09T15:45:54.213327Z | Cached | 0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59 |
| 3.1.4 | 2024-01-04T03:51:45.541663Z | Cached | 12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec |
| 3.1.5 | 2024-06-10T14:23:19.025398Z | Cached | 9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65 |
| 3.1.6 | 2024-10-17T11:43:56.147795Z | Cached | 5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984 |
| 3.2.0 | 2026-09-07T11:16:26.455977Z | Cached | a36d119c13416516a7b5913fbe8af8531e11633d784c550b2125f76c758524ec |
Dependencies
meta "^1.18.0"