diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c662b7..b83040f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,82 +1,107 @@ -### 3.1.0 +## NEXT + +* 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 +## 3.0.2 * Added `FakePlatform.copyWith` function. -### 3.0.1 +## 3.0.1 * Added string constants for each of the supported platforms for use in switch statements. -### 3.0.0 +## 3.0.0 * First stable null safe release. -### 3.0.0-nullsafety.4 +## 3.0.0-nullsafety.4 * Update supported SDK range. -### 3.0.0-nullsafety.3 +## 3.0.0-nullsafety.3 * Update supported SDK range. -### 3.0.0-nullsafety.2 +## 3.0.0-nullsafety.2 * Update supported SDK range. -### 3.0.0-nullsafety.1 +## 3.0.0-nullsafety.1 * Migrate package to null-safe dart. -### 2.2.1 +## 2.2.1 * Add `operatingSystemVersion` -### 2.2.0 +## 2.2.0 * Declare compatibility with Dart 2 stable * Update dependency on `package:test` to 1.0 -### 2.1.2 +## 2.1.2 * Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use. -### 2.1.1 +## 2.1.1 * Bumped maximum Dart SDK version to 2.0.0-dev.infinity -### 2.1.0 +## 2.1.0 * Added `localeName` * Bumped minimum Dart SDK version to 1.24.0-dev.0.0 -### 2.0.0 +## 2.0.0 * Added `stdinSupportsAnsi` and `stdinSupportsAnsi` * Removed `ansiSupported` -### 1.1.1 +## 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 +## 1.1.0 * Added `ansiSupported` * Bumped minimum Dart SDK version to 1.23.0-dev.9.0 -#### 1.0.2 +## 1.0.2 * Minor doc updates -#### 1.0.1 +## 1.0.1 * Added const constructors for `Platform` and `LocalPlatform` -#### 1.0.0 +## 1.0.0 * Initial version diff --git a/README.md b/README.md index 85d2b80..44932a6 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,5 @@ [![Pub](https://img.shields.io/pub/v/platform.svg)](https://pub.dartlang.org/packages/platform) -## Moved - -The source for the `platform` package has moved to [the `flutter/packages` -repository](https://github.com/flutter/packages/tree/main/packages/platform). - ------ - A generic platform abstraction for Dart. Like `dart:io`, `package:platform` supplies a rich, Dart-idiomatic API for diff --git a/analysis_options.yaml b/analysis_options.yaml index 8fbd2e4..4544442 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: errors: diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..3a85790 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..b0bf20b --- /dev/null +++ b/example/README.md @@ -0,0 +1,2 @@ +A small example application demonstrating how to use the platform information +APIs in `package:platform`. \ No newline at end of file diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..dee8927 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/example/bin/example.dart b/example/bin/example.dart new file mode 100644 index 0000000..59693e3 --- /dev/null +++ b/example/bin/example.dart @@ -0,0 +1,15 @@ +import 'package:platform/platform.dart'; + +void main(List arguments) { + const LocalPlatform platform = LocalPlatform(); + + print('Operating System: ${platform.operatingSystem}.'); + print('Local Hostname: ${platform.localHostname}.'); + print('Number of Processors: ${platform.numberOfProcessors}.'); + print('Path Separator: ${platform.pathSeparator}.'); + print('Locale Name: ${platform.localeName}.'); + print('Stdin Supports ANSI: ${platform.stdinSupportsAnsi}.'); + print('Stdout Supports ANSI: ${platform.stdoutSupportsAnsi}.'); + print('Executable Arguments: ${platform.executableArguments}.'); + print('Dart Version: ${platform.version}.'); +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml new file mode 100644 index 0000000..35107a7 --- /dev/null +++ b/example/pubspec.yaml @@ -0,0 +1,14 @@ +name: example +description: Demonstrates how to use the platform api. +version: 1.0.0 +publish_to: none + +environment: + sdk: ^3.2.0 + +dependencies: + platform: + path: ../ + +dev_dependencies: + lints: ^4.0.0 diff --git a/lib/platform.dart b/lib/platform.dart index 2770219..f096dcb 100644 --- a/lib/platform.dart +++ b/lib/platform.dart @@ -1,8 +1,8 @@ -// Copyright (c) 2017, 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. +// 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. +// Core interfaces & classes. export 'src/interface/local_platform.dart'; export 'src/interface/platform.dart'; export 'src/testing/fake_platform.dart'; diff --git a/lib/src/interface/local_platform.dart b/lib/src/interface/local_platform.dart index d4b18ab..c24c01b 100644 --- a/lib/src/interface/local_platform.dart +++ b/lib/src/interface/local_platform.dart @@ -1,6 +1,6 @@ -// Copyright (c) 2017, 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. +// 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; diff --git a/lib/src/interface/platform.dart b/lib/src/interface/platform.dart index 354ae07..dcc47be 100644 --- a/lib/src/interface/platform.dart +++ b/lib/src/interface/platform.dart @@ -1,6 +1,6 @@ -// Copyright (c) 2017, 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. +// 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:convert'; diff --git a/lib/src/testing/fake_platform.dart b/lib/src/testing/fake_platform.dart index 7b407cd..0c028ca 100644 --- a/lib/src/testing/fake_platform.dart +++ b/lib/src/testing/fake_platform.dart @@ -1,6 +1,6 @@ -// Copyright (c) 2017, 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. +// 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:convert'; @@ -12,7 +12,7 @@ class FakePlatform extends Platform { /// /// Unspecified properties will *not* be assigned default values (they will /// remain `null`). If an unset non-null value is read, a [StateError] will - /// be thrown instead of returnin `null`. + /// be thrown instead of returning `null`. FakePlatform({ int? numberOfProcessors, String? pathSeparator, @@ -69,27 +69,30 @@ class FakePlatform extends Platform { /// [json] must be a JSON string that matches the encoding produced by /// [toJson]. factory FakePlatform.fromJson(String json) { - Map map = JsonDecoder().convert(json); + final map = const JsonDecoder().convert(json) as Map; return FakePlatform( - numberOfProcessors: map['numberOfProcessors'], - pathSeparator: map['pathSeparator'], - operatingSystem: map['operatingSystem'], - operatingSystemVersion: map['operatingSystemVersion'], - localHostname: map['localHostname'], - environment: map['environment'].cast(), - executable: map['executable'], - resolvedExecutable: map['resolvedExecutable'], - script: Uri.parse(map['script']), - executableArguments: map['executableArguments'].cast(), - packageConfig: map['packageConfig'], - version: map['version'], - stdinSupportsAnsi: map['stdinSupportsAnsi'], - stdoutSupportsAnsi: map['stdoutSupportsAnsi'], - localeName: map['localeName'], + numberOfProcessors: map['numberOfProcessors'] as int?, + pathSeparator: map['pathSeparator'] as String?, + operatingSystem: map['operatingSystem'] as String?, + operatingSystemVersion: map['operatingSystemVersion'] as String?, + localHostname: map['localHostname'] as String?, + environment: + (map['environment'] as Map).cast(), + executable: map['executable'] as String?, + resolvedExecutable: map['resolvedExecutable'] as String?, + script: Uri.parse(map['script'] as String), + executableArguments: + (map['executableArguments'] as List).cast(), + packageConfig: map['packageConfig'] as String?, + version: map['version'] as String?, + stdinSupportsAnsi: map['stdinSupportsAnsi'] as bool?, + stdoutSupportsAnsi: map['stdoutSupportsAnsi'] as bool?, + localeName: map['localeName'] as String?, ); } - /// Creates a new [FakePlatform] from this one, with some properties replaced by the given properties. + /// Creates a new [FakePlatform] from this one, with some properties replaced + /// by the given properties. FakePlatform copyWith({ int? numberOfProcessors, String? pathSeparator, diff --git a/pubspec.yaml b/pubspec.yaml index 1914ca5..0c60d5a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,16 @@ name: platform -version: 3.1.0 -description: A pluggable, mockable platform abstraction for Dart. -homepage: https://github.com/google/platform.dart +description: A pluggable, mockable platform information abstraction for Dart. +repository: https://github.com/dart-lang/platform +issue_tracker: https://github.com/dart-lang/platform/issues +version: 3.1.4 environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ^3.2.0 dev_dependencies: - lints: ^1.0.1 + dart_flutter_team_lints: ^3.1.0 test: ^1.16.8 + +topics: + - information + - platform diff --git a/test/fake_platform_test.dart b/test/fake_platform_test.dart index 0c6034c..1aa7cbf 100644 --- a/test/fake_platform_test.dart +++ b/test/fake_platform_test.dart @@ -1,6 +1,6 @@ -// Copyright (c) 2017, 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. +// 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; @@ -30,7 +30,7 @@ void main() { setUp(() { fake = FakePlatform(); - local = LocalPlatform(); + local = const LocalPlatform(); }); group('fromPlatform', () { @@ -43,7 +43,7 @@ void main() { }); test('convertsPropertiesToMutable', () { - String key = fake.environment.keys.first; + final key = fake.environment.keys.first; expect(fake.environment[key], local.environment[key]); fake.environment[key] = 'FAKE'; @@ -62,7 +62,7 @@ void main() { }); test('overrides a value, but leaves others intact', () { - FakePlatform copy = fake.copyWith( + final copy = fake.copyWith( numberOfProcessors: -1, ); expect(copy.numberOfProcessors, equals(-1)); @@ -96,7 +96,7 @@ void main() { stdoutSupportsAnsi: true, localeName: 'local', ); - FakePlatform copy = fake.copyWith( + final copy = fake.copyWith( numberOfProcessors: local.numberOfProcessors, pathSeparator: local.pathSeparator, operatingSystem: local.operatingSystem, @@ -119,7 +119,7 @@ void main() { group('json', () { test('fromJson', () { - String json = io.File('test/platform.json').readAsStringSync(); + final json = io.File('test/platform.json').readAsStringSync(); fake = FakePlatform.fromJson(json); expect(fake.numberOfProcessors, 8); expect(fake.pathSeparator, '/'); @@ -147,7 +147,7 @@ void main() { }); test('Throws when unset non-null values are read', () { - final FakePlatform platform = FakePlatform(); + final platform = FakePlatform(); expect(() => platform.numberOfProcessors, throwsA(isStateError)); expect(() => platform.pathSeparator, throwsA(isStateError));