Skip to content

Commit

Permalink
[platform] Import the platform package (#4613)
Browse files Browse the repository at this point in the history
Imports the `packages` platform from https://github.com/google/platform.dart
- As there is not much history in the package, this imports it as a copy instead of going through the process of actually merging the commit history of that repo into this one.
- The only changes relative to the current source in that repo are:
  - Adjustments for repo conventions (such as removing analysis_options.yaml and fixing the resulting issues).
  - Addressing dart-archive/platform#44

Part of flutter/flutter#130915
  • Loading branch information
stuartmorgan authored Aug 16, 2023
1 parent 63ba60c commit 3a183b7
Show file tree
Hide file tree
Showing 15 changed files with 815 additions and 1 deletion.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ packages/multicast_dns/** @dnfield
packages/palette_generator/** @gspencergoog
packages/path_provider/** @stuartmorgan
packages/pigeon/** @tarrinneal
packages/platform/** @stuartmorgan
packages/plugin_platform_interface/** @stuartmorgan
packages/pointer_interceptor/** @ditman
packages/quick_actions/** @bparrishMines
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ These packages are also available on [pub](https://pub.dartlang.org/flutter/pack
## Issues

Please file any issues, bugs, or feature requests in the [main flutter
repo](https://github.com/flutter/flutter/issues/new).
repo](https://github.com/flutter/flutter/issues/new).
Issues pertaining to this repository are [labeled
"package"](https://github.com/flutter/flutter/issues?q=is%3Aopen+is%3Aissue+label%3Apackage).

Expand Down Expand Up @@ -64,6 +64,7 @@ These are the packages hosted in this repository:
| [palette\_generator](./packages/palette_generator/) | [![pub package](https://img.shields.io/pub/v/palette_generator.svg)](https://pub.dartlang.org/packages/palette_generator) | [![pub points](https://img.shields.io/pub/points/palette_generator)](https://pub.dev/packages/palette_generator/score) | [![popularity](https://img.shields.io/pub/popularity/palette_generator)](https://pub.dev/packages/palette_generator/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p:%20palette_generator?label=)](https://github.com/flutter/flutter/labels/p%3A%20palette_generator) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p:%20palette_generator?label=)](https://github.com/flutter/packages/labels/p%3A%20palette_generator) |
| [path\_provider](./packages/path_provider/) | [![pub package](https://img.shields.io/pub/v/path_provider.svg)](https://pub.dev/packages/path_provider) | [![pub points](https://img.shields.io/pub/points/path_provider)](https://pub.dev/packages/path_provider/score) | [![popularity](https://img.shields.io/pub/popularity/path_provider)](https://pub.dev/packages/path_provider/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p:%20path_provider?label=)](https://github.com/flutter/flutter/labels/p%3A%20path_provider) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p:%20path_provider?label=)](https://github.com/flutter/packages/labels/p%3A%20path_provider) |
| [pigeon](./packages/pigeon/) | [![pub package](https://img.shields.io/pub/v/pigeon.svg)](https://pub.dev/packages/pigeon) | [![pub points](https://img.shields.io/pub/points/pigeon)](https://pub.dev/packages/pigeon/score) | [![popularity](https://img.shields.io/pub/popularity/pigeon)](https://pub.dev/packages/pigeon/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/pigeon?label=)](https://github.com/flutter/flutter/labels/pigeon) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p:%20pigeon?label=)](https://github.com/flutter/packages/labels/p%3A%20pigeon) |
| [platform](./packages/platform/) | [![pub package](https://img.shields.io/pub/v/platform.svg)](https://pub.dev/packages/platform) | [![pub points](https://img.shields.io/pub/points/platform)](https://pub.dev/packages/platform/score) | [![popularity](https://img.shields.io/pub/popularity/platform)](https://pub.dev/packages/platform/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p:%20platform?label=)](https://github.com/flutter/flutter/labels/p%3A%20platform) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p:%20platform?label=)](https://github.com/flutter/packages/labels/p%3A%20platform) |
| [pointer\_interceptor](./packages/pointer_interceptor/) | [![pub package](https://img.shields.io/pub/v/pointer_interceptor.svg)](https://pub.dev/packages/pointer_interceptor) | [![pub points](https://img.shields.io/pub/points/pointer_interceptor)](https://pub.dev/packages/pointer_interceptor/score) | [![popularity](https://img.shields.io/pub/popularity/pointer_interceptor)](https://pub.dev/packages/pointer_interceptor/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p:%20pointer_interceptor?label=)](https://github.com/flutter/flutter/labels/p%3A%20pointer_interceptor) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p:%20pointer_interceptor?label=)](https://github.com/flutter/packages/labels/p%3A%20pointer_interceptor) |
| [plugin\_platform\_interface](./packages/plugin_platform_interface/) | [![pub package](https://img.shields.io/pub/v/plugin_platform_interface.svg)](https://pub.dev/packages/plugin_platform_interface) | [![pub points](https://img.shields.io/pub/points/plugin_platform_interface)](https://pub.dev/packages/plugin_platform_interface/score) | [![popularity](https://img.shields.io/pub/popularity/plugin_platform_interface)](https://pub.dev/packages/plugin_platform_interface/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p:%20plugin_platform_interface?label=)](https://github.com/flutter/flutter/labels/p%3A%20plugin_platform_interface) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p:%20plugin_platform_interface?label=)](https://github.com/flutter/packages/labels/p%3A%20plugin_platform_interface) |
| [quick\_actions](./packages/quick_actions/) | [![pub package](https://img.shields.io/pub/v/quick_actions.svg)](https://pub.dev/packages/quick_actions) | [![pub points](https://img.shields.io/pub/points/quick_actions)](https://pub.dev/packages/quick_actions/score) | [![popularity](https://img.shields.io/pub/popularity/quick_actions)](https://pub.dev/packages/quick_actions/score) | [![GitHub issues by-label](https://img.shields.io/github/issues/flutter/flutter/p:%20quick_actions?label=)](https://github.com/flutter/flutter/labels/p%3A%20quick_actions) | [![GitHub pull requests by-label](https://img.shields.io/github/issues-pr/flutter/packages/p:%20quick_actions?label=)](https://github.com/flutter/packages/labels/p%3A%20quick_actions) |
Expand Down
17 changes: 17 additions & 0 deletions packages/platform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Dart template
# Don’t commit the following directories created by pub.
.buildlog
.dart_tool/
.pub/
build/
packages
.packages

# Include when developing application packages.
pubspec.lock

# IDE
.project
.settings
.idea
.c9
6 changes: 6 additions & 0 deletions packages/platform/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Below is a list of people and organizations that have contributed
# to the Process project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
87 changes: 87 additions & 0 deletions packages/platform/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
## 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.copyWith` function.

## 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:test` to 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 `stdinSupportsAnsi` and `stdinSupportsAnsi`
* Removed `ansiSupported`

## 1.1.1

* Updated `LocalPlatform` to use new `dart.io` API 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 `Platform` and `LocalPlatform`

## 1.0.0

* Initial version
25 changes: 25 additions & 0 deletions packages/platform/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2013 The Flutter Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10 changes: 10 additions & 0 deletions packages/platform/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[![Pub](https://img.shields.io/pub/v/platform.svg)](https://pub.dartlang.org/packages/platform)

A generic platform abstraction for Dart.

Like `dart:io`, `package:platform` supplies a rich, Dart-idiomatic API for
accessing platform-specific information.

`package:platform` provides a lightweight wrapper around the static `Platform`
properties that exist in `dart:io`. However, it uses instance properties rather
than static properties, making it possible to mock out in tests.
1 change: 1 addition & 0 deletions packages/platform/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test_on: vm
8 changes: 8 additions & 0 deletions packages/platform/lib/platform.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// Core interfaces & classes.
export 'src/interface/local_platform.dart';
export 'src/interface/platform.dart';
export 'src/testing/fake_platform.dart';
58 changes: 58 additions & 0 deletions packages/platform/lib/src/interface/local_platform.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io' as io show Platform, stdin, stdout;

import 'platform.dart';

/// `Platform` implementation that delegates directly to `dart:io`.
class LocalPlatform extends Platform {
/// Creates a new [LocalPlatform].
const LocalPlatform();

@override
int get numberOfProcessors => io.Platform.numberOfProcessors;

@override
String get pathSeparator => io.Platform.pathSeparator;

@override
String get operatingSystem => io.Platform.operatingSystem;

@override
String get operatingSystemVersion => io.Platform.operatingSystemVersion;

@override
String get localHostname => io.Platform.localHostname;

@override
Map<String, String> get environment => io.Platform.environment;

@override
String get executable => io.Platform.executable;

@override
String get resolvedExecutable => io.Platform.resolvedExecutable;

@override
Uri get script => io.Platform.script;

@override
List<String> get executableArguments => io.Platform.executableArguments;

@override
String? get packageConfig => io.Platform.packageConfig;

@override
String get version => io.Platform.version;

@override
bool get stdinSupportsAnsi => io.stdin.supportsAnsiEscapes;

@override
bool get stdoutSupportsAnsi => io.stdout.supportsAnsiEscapes;

@override
String get localeName => io.Platform.localeName;
}
Loading

0 comments on commit 3a183b7

Please sign in to comment.