From 5a2f03601b0ca22bc67a528783cc657e908fa3d8 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 2 Mar 2023 11:23:38 -0800 Subject: [PATCH] Move to pkg:dart_flutter_team_lints, require Dart 2.19 (#883) --- .github/workflows/cronet.yml | 2 +- .github/workflows/dart.yml | 30 ++++++++--------- analysis_options.yaml | 18 +---------- pkgs/cronet_http/CHANGELOG.md | 4 +++ .../cronet_configuration_test.dart | 1 + pkgs/cronet_http/example/pubspec.yaml | 5 +-- pkgs/cronet_http/lib/cronet_http.dart | 1 + pkgs/cronet_http/lib/src/cronet_client.dart | 3 +- pkgs/cronet_http/lib/src/messages.dart | 24 +++++--------- pkgs/cronet_http/pubspec.yaml | 6 ++-- .../tool/prepare_for_embedded.dart | 1 + pkgs/cupertino_http/CHANGELOG.md | 4 +++ .../example/integration_test/error_test.dart | 1 + pkgs/cupertino_http/example/pubspec.yaml | 4 +-- pkgs/cupertino_http/lib/cupertino_http.dart | 2 ++ .../cupertino_http/lib/src/cupertino_api.dart | 32 +++++++++---------- .../lib/src/cupertino_client.dart | 1 + pkgs/cupertino_http/lib/src/utils.dart | 4 +-- pkgs/cupertino_http/pubspec.yaml | 6 ++-- pkgs/http/CHANGELOG.md | 2 +- pkgs/http/lib/http.dart | 2 ++ pkgs/http/lib/retry.dart | 2 +- pkgs/http/lib/src/byte_stream.dart | 2 +- pkgs/http/lib/src/io_streamed_response.dart | 24 +++++--------- pkgs/http/lib/src/multipart_request.dart | 2 +- pkgs/http/lib/src/request.dart | 5 ++- pkgs/http/lib/src/response.dart | 20 ++++-------- pkgs/http/lib/src/streamed_request.dart | 5 ++- pkgs/http/lib/src/streamed_response.dart | 24 +++++--------- pkgs/http/pubspec.yaml | 4 +-- .../test/html/client_conformance_test.dart | 3 +- pkgs/http/test/html/client_test.dart | 2 ++ .../http/test/html/streamed_request_test.dart | 2 ++ .../http/test/io/client_conformance_test.dart | 3 +- pkgs/http/test/io/client_test.dart | 15 +++++---- pkgs/http/test/io/http_test.dart | 18 +++++------ pkgs/http/test/io/multipart_test.dart | 1 + pkgs/http/test/io/request_test.dart | 1 + pkgs/http/test/io/streamed_request_test.dart | 1 + .../CHANGELOG.md | 3 -- .../bin/generate_server_wrappers.dart | 1 + .../example/client_test.dart | 2 +- .../pubspec.yaml | 7 ++-- 43 files changed, 139 insertions(+), 161 deletions(-) delete mode 100644 pkgs/http_client_conformance_tests/CHANGELOG.md diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index c39affcddf..0b35e16aae 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -36,7 +36,7 @@ jobs: name: Install dependencies run: flutter pub get - name: Check formatting - run: flutter format --output=none --set-exit-if-changed . + run: dart format --output=none --set-exit-if-changed . if: always() && steps.install.outcome == 'success' - name: Analyze code run: flutter analyze --fatal-infos diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 6724ebbd48..b7d92fcd13 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -40,23 +40,23 @@ jobs: - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyze_and_format; Dart 2.14.0; PKGS: pkgs/http, pkgs/http_client_conformance_tests; `dart analyze --fatal-infos`" + name: "analyze_and_format; Dart 2.19.0; PKGS: pkgs/http, pkgs/http_client_conformance_tests; `dart analyze --fatal-infos`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0;packages:pkgs/http-pkgs/http_client_conformance_tests;commands:analyze" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:pkgs/http-pkgs/http_client_conformance_tests;commands:analyze" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0;packages:pkgs/http-pkgs/http_client_conformance_tests - os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0 + os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:pkgs/http-pkgs/http_client_conformance_tests + os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: - sdk: "2.14.0" + sdk: "2.19.0" - id: checkout name: Checkout repository uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c @@ -157,23 +157,23 @@ jobs: if: "always() && steps.pkgs_http_client_conformance_tests_pub_upgrade.conclusion == 'success'" working-directory: pkgs/http_client_conformance_tests job_005: - name: "unit_test; Dart 2.14.0; PKG: pkgs/http; `dart test --platform chrome`" + name: "unit_test; Dart 2.19.0; PKG: pkgs/http; `dart test --platform chrome`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0;packages:pkgs/http;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:pkgs/http;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0;packages:pkgs/http - os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0 + os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:pkgs/http + os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: - sdk: "2.14.0" + sdk: "2.19.0" - id: checkout name: Checkout repository uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c @@ -192,23 +192,23 @@ jobs: - job_003 - job_004 job_006: - name: "unit_test; Dart 2.14.0; PKG: pkgs/http; `dart test --platform vm`" + name: "unit_test; Dart 2.19.0; PKG: pkgs/http; `dart test --platform vm`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0;packages:pkgs/http;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:pkgs/http;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0;packages:pkgs/http - os:ubuntu-latest;pub-cache-hosted;sdk:2.14.0 + os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:pkgs/http + os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: - sdk: "2.14.0" + sdk: "2.19.0" - id: checkout name: Checkout repository uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c diff --git a/analysis_options.yaml b/analysis_options.yaml index fac854658e..7d741bd4f1 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: language: @@ -9,36 +9,20 @@ analyzer: linter: rules: - avoid_bool_literals_in_conditional_expressions - - avoid_catching_errors - avoid_classes_with_only_static_members - - avoid_dynamic_calls - avoid_private_typedef_functions - avoid_returning_this - avoid_unused_constructor_parameters - cascade_invocations - comment_references - - directives_ordering - join_return_with_assignment - - lines_longer_than_80_chars - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - - omit_local_variable_types - - only_throw_errors - - prefer_asserts_in_initializer_lists - prefer_const_constructors - prefer_const_declarations - prefer_expression_function_bodies - prefer_relative_imports - - prefer_single_quotes - - sort_pub_dependencies - test_types_in_equals - - throw_in_finally - - type_annotate_public_apis - - unawaited_futures - - unnecessary_lambdas - - unnecessary_parenthesis - - unnecessary_statements - - use_is_even_rather_than_modulo - use_string_buffers - use_super_parameters diff --git a/pkgs/cronet_http/CHANGELOG.md b/pkgs/cronet_http/CHANGELOG.md index 2f1568ede8..3be15bc399 100644 --- a/pkgs/cronet_http/CHANGELOG.md +++ b/pkgs/cronet_http/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.1-dev + +* Require Dart 2.19 + ## 0.2.0 * Restructure `package:cronet_http` to offer a diff --git a/pkgs/cronet_http/example/integration_test/cronet_configuration_test.dart b/pkgs/cronet_http/example/integration_test/cronet_configuration_test.dart index fc2747d18e..b6e7205489 100644 --- a/pkgs/cronet_http/example/integration_test/cronet_configuration_test.dart +++ b/pkgs/cronet_http/example/integration_test/cronet_configuration_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// Tests various [CronetEngine] configurations. +library; import 'dart:io'; diff --git a/pkgs/cronet_http/example/pubspec.yaml b/pkgs/cronet_http/example/pubspec.yaml index d1bf2b7719..b38ebb043b 100644 --- a/pkgs/cronet_http/example/pubspec.yaml +++ b/pkgs/cronet_http/example/pubspec.yaml @@ -4,7 +4,7 @@ description: Demonstrates how to use the cronet_http plugin. publish_to: 'none' environment: - sdk: ">=2.17.5 <3.0.0" + sdk: ">=2.19.0 <3.0.0" dependencies: cached_network_image: ^3.2.3 @@ -16,13 +16,14 @@ dependencies: http: ^0.13.5 dev_dependencies: - flutter_lints: ^1.0.0 + dart_flutter_team_lints: ^1.0.0 flutter_test: sdk: flutter http_client_conformance_tests: path: ../../http_client_conformance_tests/ integration_test: sdk: flutter + test: ^1.23.1 flutter: uses-material-design: true diff --git a/pkgs/cronet_http/lib/cronet_http.dart b/pkgs/cronet_http/lib/cronet_http.dart index e4f49c3508..e41af71f9e 100644 --- a/pkgs/cronet_http/lib/cronet_http.dart +++ b/pkgs/cronet_http/lib/cronet_http.dart @@ -50,6 +50,7 @@ /// After the above setup, calling [Client] methods or any of the /// `package:http` convenient functions (e.g. [get]) will result in /// [CronetClient] being used on Android. +library; import 'package:http/http.dart'; diff --git a/pkgs/cronet_http/lib/src/cronet_client.dart b/pkgs/cronet_http/lib/src/cronet_client.dart index 7979f49f5f..8799d43166 100644 --- a/pkgs/cronet_http/lib/src/cronet_client.dart +++ b/pkgs/cronet_http/lib/src/cronet_client.dart @@ -11,6 +11,7 @@ /// [`WidgetsFlutterBinding.ensureInitialized`](https://api.flutter.dev/flutter/widgets/WidgetsFlutterBinding/ensureInitialized.html) /// or /// [`runApp`](https://api.flutter.dev/flutter/widgets/runApp.html). +library; import 'dart:async'; @@ -19,7 +20,7 @@ import 'package:http/http.dart'; import 'messages.dart' as messages; -late final _api = messages.HttpApi(); +final _api = messages.HttpApi(); final Finalizer _cronetEngineFinalizer = Finalizer(_api.freeEngine); diff --git a/pkgs/cronet_http/lib/src/messages.dart b/pkgs/cronet_http/lib/src/messages.dart index 47e0a920e9..8b6c3910f7 100644 --- a/pkgs/cronet_http/lib/src/messages.dart +++ b/pkgs/cronet_http/lib/src/messages.dart @@ -298,29 +298,21 @@ class _HttpApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: - return CreateEngineRequest.decode(readValue(buffer)!); + case 128: return CreateEngineRequest.decode(readValue(buffer)!); - case 129: - return CreateEngineResponse.decode(readValue(buffer)!); + case 129: return CreateEngineResponse.decode(readValue(buffer)!); - case 130: - return EventMessage.decode(readValue(buffer)!); + case 130: return EventMessage.decode(readValue(buffer)!); - case 131: - return ReadCompleted.decode(readValue(buffer)!); + case 131: return ReadCompleted.decode(readValue(buffer)!); - case 132: - return ResponseStarted.decode(readValue(buffer)!); + case 132: return ResponseStarted.decode(readValue(buffer)!); - case 133: - return StartRequest.decode(readValue(buffer)!); + case 133: return StartRequest.decode(readValue(buffer)!); - case 134: - return StartResponse.decode(readValue(buffer)!); + case 134: return StartResponse.decode(readValue(buffer)!); - default: - return super.readValueOfType(type, buffer); + default: return super.readValueOfType(type, buffer); } } } diff --git a/pkgs/cronet_http/pubspec.yaml b/pkgs/cronet_http/pubspec.yaml index 16b63a301d..9745e61a9e 100644 --- a/pkgs/cronet_http/pubspec.yaml +++ b/pkgs/cronet_http/pubspec.yaml @@ -1,11 +1,11 @@ name: cronet_http description: > An Android Flutter plugin that provides access to the Cronet HTTP client. -version: 0.2.0 +version: 0.2.1-dev repository: https://github.com/dart-lang/http/tree/master/pkgs/cronet_http environment: - sdk: ">=2.17.5 <3.0.0" + sdk: ">=2.19.0 <3.0.0" flutter: ">=3.0.0" dependencies: @@ -14,7 +14,7 @@ dependencies: http: ^0.13.4 dev_dependencies: - lints: ^1.0.0 + dart_flutter_team_lints: ^1.0.0 pigeon: ^3.2.3 xml: ^6.1.0 yaml_edit: ^2.0.3 diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index 89dce19ef0..8791a2f500 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -18,6 +18,7 @@ /// can be run to update package:cronet_http_embedded. /// /// NOTE: This script modifies the above files in place. +library; import 'dart:io'; diff --git a/pkgs/cupertino_http/CHANGELOG.md b/pkgs/cupertino_http/CHANGELOG.md index 85a04f1569..6e934a4711 100644 --- a/pkgs/cupertino_http/CHANGELOG.md +++ b/pkgs/cupertino_http/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.2-dev + +* Require Dart 2.19 + ## 0.1.1 * Add a `URLSession.sessionDescription` field. diff --git a/pkgs/cupertino_http/example/integration_test/error_test.dart b/pkgs/cupertino_http/example/integration_test/error_test.dart index 4c7ad63dba..c04af1e9fa 100644 --- a/pkgs/cupertino_http/example/integration_test/error_test.dart +++ b/pkgs/cupertino_http/example/integration_test/error_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @Skip('Error tests cannot currently be written. See comments in this file.') +library; import 'package:integration_test/integration_test.dart'; import 'package:test/test.dart'; diff --git a/pkgs/cupertino_http/example/pubspec.yaml b/pkgs/cupertino_http/example/pubspec.yaml index 954a9c7022..fd8938989b 100644 --- a/pkgs/cupertino_http/example/pubspec.yaml +++ b/pkgs/cupertino_http/example/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: 'none' version: 1.0.0+1 environment: - sdk: ">=2.17.3 <3.0.0" + sdk: ">=2.19.0 <3.0.0" dependencies: cached_network_image: ^3.2.3 @@ -18,7 +18,7 @@ dependencies: http: ^0.13.5 dev_dependencies: - flutter_lints: ^2.0.0 + dart_flutter_team_lints: ^1.0.0 flutter_test: sdk: flutter http_client_conformance_tests: diff --git a/pkgs/cupertino_http/lib/cupertino_http.dart b/pkgs/cupertino_http/lib/cupertino_http.dart index 4fd041ce25..89af0a3c1b 100644 --- a/pkgs/cupertino_http/lib/cupertino_http.dart +++ b/pkgs/cupertino_http/lib/cupertino_http.dart @@ -74,6 +74,8 @@ /// task.resume(); /// } /// ``` +library; + import 'package:http/http.dart'; import 'src/cupertino_client.dart'; diff --git a/pkgs/cupertino_http/lib/src/cupertino_api.dart b/pkgs/cupertino_http/lib/src/cupertino_api.dart index 1c6125d012..59d1187803 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_api.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_api.dart @@ -24,6 +24,7 @@ /// task.resume(); /// } /// ``` +library; import 'dart:ffi'; import 'dart:isolate'; @@ -114,7 +115,7 @@ enum URLRequestNetworkService { /// /// See [NSError](https://developer.apple.com/documentation/foundation/nserror) class Error extends _ObjectHolder { - Error._(ncb.NSError c) : super(c); + Error._(super.c); /// The numeric code for the error e.g. -1003 (kCFURLErrorCannotFindHost). /// @@ -161,7 +162,7 @@ class Error extends _ObjectHolder { /// See [NSURLSessionConfiguration](https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration) class URLSessionConfiguration extends _ObjectHolder { - URLSessionConfiguration._(ncb.NSURLSessionConfiguration c) : super(c); + URLSessionConfiguration._(super.c); /// A configuration suitable for performing HTTP uploads and downloads in /// the background. @@ -331,7 +332,7 @@ class URLSessionConfiguration /// /// See [NSData](https://developer.apple.com/documentation/foundation/nsdata) class Data extends _ObjectHolder { - Data._(ncb.NSData c) : super(c); + Data._(super.c); // A new [Data] from an existing one. // @@ -388,9 +389,9 @@ class Data extends _ObjectHolder { class MutableData extends Data { final ncb.NSMutableData _mutableData; - MutableData._(ncb.NSMutableData c) + MutableData._(ncb.NSMutableData super.c) : _mutableData = c, - super._(c); + super._(); /// A new empty [MutableData]. factory MutableData.empty() => @@ -423,7 +424,7 @@ class MutableData extends Data { /// /// See [NSURLResponse](https://developer.apple.com/documentation/foundation/nsurlresponse) class URLResponse extends _ObjectHolder { - URLResponse._(ncb.NSURLResponse c) : super(c); + URLResponse._(super.c); factory URLResponse._exactURLResponseType(ncb.NSURLResponse response) { if (ncb.NSHTTPURLResponse.isInstance(response)) { @@ -455,9 +456,9 @@ class URLResponse extends _ObjectHolder { class HTTPURLResponse extends URLResponse { final ncb.NSHTTPURLResponse _httpUrlResponse; - HTTPURLResponse._(ncb.NSHTTPURLResponse c) + HTTPURLResponse._(ncb.NSHTTPURLResponse super.c) : _httpUrlResponse = c, - super._(c); + super._(); /// The HTTP status code of the response (e.g. 200). /// @@ -495,7 +496,7 @@ enum URLSessionTaskState { /// /// See [NSURLSessionTask](https://developer.apple.com/documentation/foundation/nsurlsessiontask) class URLSessionTask extends _ObjectHolder { - URLSessionTask._(ncb.NSURLSessionTask c) : super(c); + URLSessionTask._(super.c); /// Cancels the task. /// @@ -657,7 +658,7 @@ class URLSessionTask extends _ObjectHolder { /// /// See [NSURLSessionDownloadTask](https://developer.apple.com/documentation/foundation/nsurlsessiondownloadtask) class URLSessionDownloadTask extends URLSessionTask { - URLSessionDownloadTask._(ncb.NSURLSessionDownloadTask c) : super._(c); + URLSessionDownloadTask._(ncb.NSURLSessionDownloadTask super.c) : super._(); @override String toString() => _toStringHelper('URLSessionDownloadTask'); @@ -667,7 +668,7 @@ class URLSessionDownloadTask extends URLSessionTask { /// /// See [NSURLRequest](https://developer.apple.com/documentation/foundation/nsurlrequest) class URLRequest extends _ObjectHolder { - URLRequest._(ncb.NSURLRequest c) : super(c); + URLRequest._(super.c); /// Creates a request for a URL. /// @@ -751,9 +752,9 @@ class URLRequest extends _ObjectHolder { class MutableURLRequest extends URLRequest { final ncb.NSMutableURLRequest _mutableUrlRequest; - MutableURLRequest._(ncb.NSMutableURLRequest c) + MutableURLRequest._(ncb.NSMutableURLRequest super.c) : _mutableUrlRequest = c, - super._(c); + super._(); /// Creates a request for a URL. /// @@ -978,7 +979,7 @@ class URLSession extends _ObjectHolder { void Function(URLSession session, URLSessionDownloadTask task, Uri uri)? _onFinishedDownloading; - URLSession._(ncb.NSURLSession c, + URLSession._(super.c, {URLRequest? Function(URLSession session, URLSessionTask task, HTTPURLResponse response, URLRequest newRequest)? onRedirect, @@ -995,8 +996,7 @@ class URLSession extends _ObjectHolder { _onResponse = onResponse, _onData = onData, _onFinishedDownloading = onFinishedDownloading, - _onComplete = onComplete, - super(c); + _onComplete = onComplete; /// A client with reasonable default behavior. /// diff --git a/pkgs/cupertino_http/lib/src/cupertino_client.dart b/pkgs/cupertino_http/lib/src/cupertino_client.dart index b41f29e30b..45b6afdec2 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_client.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_client.dart @@ -4,6 +4,7 @@ /// A [Client] implementation based on the /// [Foundation URL Loading System](https://developer.apple.com/documentation/foundation/url_loading_system). +library; import 'dart:async'; import 'dart:io'; diff --git a/pkgs/cupertino_http/lib/src/utils.dart b/pkgs/cupertino_http/lib/src/utils.dart index e0e8a56b13..fa76bafac8 100644 --- a/pkgs/cupertino_http/lib/src/utils.dart +++ b/pkgs/cupertino_http/lib/src/utils.dart @@ -14,7 +14,7 @@ const _libName = _packageName; /// /// The "Foundation" framework is linked to Dart so no additional /// libraries need to be loaded to access those symbols. -late ncb.NativeCupertinoHttp linkedLibs = () { +final ncb.NativeCupertinoHttp linkedLibs = () { if (Platform.isMacOS || Platform.isIOS) { final lib = DynamicLibrary.process(); return ncb.NativeCupertinoHttp(lib); @@ -25,7 +25,7 @@ late ncb.NativeCupertinoHttp linkedLibs = () { /// Access to symbols that are available in the cupertino_http helper shared /// library. -late ncb.NativeCupertinoHttp helperLibs = _loadHelperLibrary(); +final ncb.NativeCupertinoHttp helperLibs = _loadHelperLibrary(); DynamicLibrary _loadHelperDynamicLibrary() { if (Platform.isMacOS || Platform.isIOS) { diff --git a/pkgs/cupertino_http/pubspec.yaml b/pkgs/cupertino_http/pubspec.yaml index 8f241a74a0..cd107fe350 100644 --- a/pkgs/cupertino_http/pubspec.yaml +++ b/pkgs/cupertino_http/pubspec.yaml @@ -2,11 +2,11 @@ name: cupertino_http description: > A macOS/iOS Flutter plugin that provides access to the Foundation URL Loading System. -version: 0.1.1 +version: 0.1.2-dev repository: https://github.com/dart-lang/http/tree/master/pkgs/cupertino_http environment: - sdk: ">=2.16.0 <3.0.0" + sdk: ">=2.19.0 <3.0.0" flutter: ">=3.0.0" dependencies: @@ -17,8 +17,8 @@ dependencies: meta: ^1.7.0 dev_dependencies: + dart_flutter_team_lints: ^1.0.0 ffigen: ^7.2.0 - lints: ^1.0.0 flutter: plugin: diff --git a/pkgs/http/CHANGELOG.md b/pkgs/http/CHANGELOG.md index 1f82be94c7..c11ad7afda 100644 --- a/pkgs/http/CHANGELOG.md +++ b/pkgs/http/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.13.6-dev * `BrowserClient` throws an exception if `send` is called after `close`. -* No longer depends on package:path. +* Require Dart 2.19 ## 0.13.5 diff --git a/pkgs/http/lib/http.dart b/pkgs/http/lib/http.dart index 34eebbbd0a..62004240c7 100644 --- a/pkgs/http/lib/http.dart +++ b/pkgs/http/lib/http.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. /// A composable, [Future]-based library for making HTTP requests. +library; + import 'dart:convert'; import 'dart:typed_data'; diff --git a/pkgs/http/lib/retry.dart b/pkgs/http/lib/retry.dart index e2ca33f2a5..a1ae73acbb 100644 --- a/pkgs/http/lib/retry.dart +++ b/pkgs/http/lib/retry.dart @@ -64,7 +64,7 @@ class RetryClient extends BaseClient { RangeError.checkNotNegative(_retries, 'retries'); } - /// Like [new RetryClient], but with a pre-computed list of [delays] + /// Like [RetryClient.new], but with a pre-computed list of [delays] /// between each retry. /// /// This will retry a request at most `delays.length` times, using each delay diff --git a/pkgs/http/lib/src/byte_stream.dart b/pkgs/http/lib/src/byte_stream.dart index eed1472bd0..6f9efca5e3 100644 --- a/pkgs/http/lib/src/byte_stream.dart +++ b/pkgs/http/lib/src/byte_stream.dart @@ -8,7 +8,7 @@ import 'dart:typed_data'; /// A stream of chunks of bytes representing a single piece of data. class ByteStream extends StreamView> { - const ByteStream(Stream> stream) : super(stream); + const ByteStream(super.stream); /// Returns a single-subscription byte stream that will emit the given bytes /// in a single chunk. diff --git a/pkgs/http/lib/src/io_streamed_response.dart b/pkgs/http/lib/src/io_streamed_response.dart index 21744858b3..95b818c2b3 100644 --- a/pkgs/http/lib/src/io_streamed_response.dart +++ b/pkgs/http/lib/src/io_streamed_response.dart @@ -4,7 +4,6 @@ import 'dart:io'; -import 'base_request.dart'; import 'streamed_response.dart'; /// An HTTP response where the response body is received asynchronously after @@ -17,22 +16,15 @@ class IOStreamedResponse extends StreamedResponse { /// [stream] should be a single-subscription stream. /// /// If [inner] is not provided, [detachSocket] will throw. - IOStreamedResponse(Stream> stream, int statusCode, - {int? contentLength, - BaseRequest? request, - Map headers = const {}, - bool isRedirect = false, - bool persistentConnection = true, - String? reasonPhrase, + IOStreamedResponse(super.stream, super.statusCode, + {super.contentLength, + super.request, + super.headers, + super.isRedirect, + super.persistentConnection, + super.reasonPhrase, HttpClientResponse? inner}) - : _inner = inner, - super(stream, statusCode, - contentLength: contentLength, - request: request, - headers: headers, - isRedirect: isRedirect, - persistentConnection: persistentConnection, - reasonPhrase: reasonPhrase); + : _inner = inner; /// Detaches the underlying socket from the HTTP server. /// diff --git a/pkgs/http/lib/src/multipart_request.dart b/pkgs/http/lib/src/multipart_request.dart index 2cb81a1d8a..79525421fb 100644 --- a/pkgs/http/lib/src/multipart_request.dart +++ b/pkgs/http/lib/src/multipart_request.dart @@ -45,7 +45,7 @@ class MultipartRequest extends BaseRequest { /// The list of files to upload for this request. final files = []; - MultipartRequest(String method, Uri url) : super(method, url); + MultipartRequest(super.method, super.url); /// The total length of the request body, in bytes. /// diff --git a/pkgs/http/lib/src/request.dart b/pkgs/http/lib/src/request.dart index bbb8448abe..1c7aa306ba 100644 --- a/pkgs/http/lib/src/request.dart +++ b/pkgs/http/lib/src/request.dart @@ -137,10 +137,9 @@ class Request extends BaseRequest { body = mapToQuery(fields, encoding: encoding); } - Request(String method, Uri url) + Request(super.method, super.url) : _defaultEncoding = utf8, - _bodyBytes = Uint8List(0), - super(method, url); + _bodyBytes = Uint8List(0); /// Freezes all mutable fields and returns a single-subscription [ByteStream] /// containing the request body. diff --git a/pkgs/http/lib/src/response.dart b/pkgs/http/lib/src/response.dart index 01899887a7..1ba7c466cf 100644 --- a/pkgs/http/lib/src/response.dart +++ b/pkgs/http/lib/src/response.dart @@ -42,20 +42,14 @@ class Response extends BaseResponse { reasonPhrase: reasonPhrase); /// Create a new HTTP response with a byte array body. - Response.bytes(List bodyBytes, int statusCode, - {BaseRequest? request, - Map headers = const {}, - bool isRedirect = false, - bool persistentConnection = true, - String? reasonPhrase}) + Response.bytes(List bodyBytes, super.statusCode, + {super.request, + super.headers, + super.isRedirect, + super.persistentConnection, + super.reasonPhrase}) : bodyBytes = toUint8List(bodyBytes), - super(statusCode, - contentLength: bodyBytes.length, - request: request, - headers: headers, - isRedirect: isRedirect, - persistentConnection: persistentConnection, - reasonPhrase: reasonPhrase); + super(contentLength: bodyBytes.length); /// Creates a new HTTP response by waiting for the full body to become /// available from a [StreamedResponse]. diff --git a/pkgs/http/lib/src/streamed_request.dart b/pkgs/http/lib/src/streamed_request.dart index faf3392d17..46519567b9 100644 --- a/pkgs/http/lib/src/streamed_request.dart +++ b/pkgs/http/lib/src/streamed_request.dart @@ -39,9 +39,8 @@ class StreamedRequest extends BaseRequest { final StreamController> _controller; /// Creates a new streaming request. - StreamedRequest(String method, Uri url) - : _controller = StreamController>(sync: true), - super(method, url); + StreamedRequest(super.method, super.url) + : _controller = StreamController>(sync: true); /// Freezes all mutable fields and returns a single-subscription [ByteStream] /// that emits the data being written to [sink]. diff --git a/pkgs/http/lib/src/streamed_response.dart b/pkgs/http/lib/src/streamed_response.dart index e082dced0e..8cc0c76f75 100644 --- a/pkgs/http/lib/src/streamed_response.dart +++ b/pkgs/http/lib/src/streamed_response.dart @@ -2,7 +2,6 @@ // 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. -import 'base_request.dart'; import 'base_response.dart'; import 'byte_stream.dart'; import 'utils.dart'; @@ -18,19 +17,12 @@ class StreamedResponse extends BaseResponse { /// Creates a new streaming response. /// /// [stream] should be a single-subscription stream. - StreamedResponse(Stream> stream, int statusCode, - {int? contentLength, - BaseRequest? request, - Map headers = const {}, - bool isRedirect = false, - bool persistentConnection = true, - String? reasonPhrase}) - : stream = toByteStream(stream), - super(statusCode, - contentLength: contentLength, - request: request, - headers: headers, - isRedirect: isRedirect, - persistentConnection: persistentConnection, - reasonPhrase: reasonPhrase); + StreamedResponse(Stream> stream, super.statusCode, + {super.contentLength, + super.request, + super.headers, + super.isRedirect, + super.persistentConnection, + super.reasonPhrase}) + : stream = toByteStream(stream); } diff --git a/pkgs/http/pubspec.yaml b/pkgs/http/pubspec.yaml index f084d767fc..2f3232a38d 100644 --- a/pkgs/http/pubspec.yaml +++ b/pkgs/http/pubspec.yaml @@ -4,7 +4,7 @@ description: A composable, multi-platform, Future-based API for HTTP requests. repository: https://github.com/dart-lang/http/tree/master/pkgs/http environment: - sdk: '>=2.14.0 <3.0.0' + sdk: '>=2.19.0 <3.0.0' dependencies: async: ^2.5.0 @@ -12,10 +12,10 @@ dependencies: meta: ^1.3.0 dev_dependencies: + dart_flutter_team_lints: ^1.0.0 fake_async: ^1.2.0 http_client_conformance_tests: path: ../http_client_conformance_tests/ - lints: '>=1.0.0 <3.0.0' shelf: ^1.1.0 stream_channel: ^2.1.0 test: ^1.16.0 diff --git a/pkgs/http/test/html/client_conformance_test.dart b/pkgs/http/test/html/client_conformance_test.dart index ab33294efb..1a94a551c2 100644 --- a/pkgs/http/test/html/client_conformance_test.dart +++ b/pkgs/http/test/html/client_conformance_test.dart @@ -3,13 +3,14 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('browser') +library; import 'package:http/browser_client.dart'; import 'package:http_client_conformance_tests/http_client_conformance_tests.dart'; import 'package:test/test.dart'; void main() { - testAll(() => BrowserClient(), + testAll(BrowserClient.new, redirectAlwaysAllowed: true, canStreamRequestBody: false, canStreamResponseBody: false); diff --git a/pkgs/http/test/html/client_test.dart b/pkgs/http/test/html/client_test.dart index 24b20dc0e0..b56b228518 100644 --- a/pkgs/http/test/html/client_test.dart +++ b/pkgs/http/test/html/client_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('browser') +library; + import 'package:http/browser_client.dart'; import 'package:http/http.dart' as http; import 'package:test/test.dart'; diff --git a/pkgs/http/test/html/streamed_request_test.dart b/pkgs/http/test/html/streamed_request_test.dart index d4d495836a..c7671734b6 100644 --- a/pkgs/http/test/html/streamed_request_test.dart +++ b/pkgs/http/test/html/streamed_request_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('browser') +library; + import 'package:http/browser_client.dart'; import 'package:http/http.dart' as http; import 'package:test/test.dart'; diff --git a/pkgs/http/test/io/client_conformance_test.dart b/pkgs/http/test/io/client_conformance_test.dart index 5eb2de676a..5d8f7f598d 100644 --- a/pkgs/http/test/io/client_conformance_test.dart +++ b/pkgs/http/test/io/client_conformance_test.dart @@ -3,11 +3,12 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'package:http/io_client.dart'; import 'package:http_client_conformance_tests/http_client_conformance_tests.dart'; import 'package:test/test.dart'; void main() { - testAll(() => IOClient()); + testAll(IOClient.new); } diff --git a/pkgs/http/test/io/client_test.dart b/pkgs/http/test/io/client_test.dart index 60903ddb93..e493931802 100644 --- a/pkgs/http/test/io/client_test.dart +++ b/pkgs/http/test/io/client_test.dart @@ -3,6 +3,8 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; + import 'dart:convert'; import 'dart:io'; @@ -149,12 +151,12 @@ void main() { }); test('runWithClient', () { - final client = http.runWithClient(() => http.Client(), () => TestClient()); + final client = http.runWithClient(http.Client.new, TestClient.new); expect(client, isA()); }); test('runWithClient Client() return', () { - final client = http.runWithClient(() => http.Client(), () => http.Client()); + final client = http.runWithClient(http.Client.new, http.Client.new); expect(client, isA()); }); @@ -162,10 +164,9 @@ void main() { late final http.Client client; late final http.Client nestedClient; http.runWithClient(() { - http.runWithClient( - () => nestedClient = http.Client(), () => TestClient2()); + http.runWithClient(() => nestedClient = http.Client(), TestClient2.new); client = http.Client(); - }, () => TestClient()); + }, TestClient.new); expect(client, isA()); expect(nestedClient, isA()); }); @@ -174,7 +175,7 @@ void main() { // Verify that calling the http.Client() factory inside nested Zones does // not provoke an infinite recursion. http.runWithClient(() { - http.runWithClient(() => http.Client(), () => http.Client()); - }, () => http.Client()); + http.runWithClient(http.Client.new, http.Client.new); + }, http.Client.new); }); } diff --git a/pkgs/http/test/io/http_test.dart b/pkgs/http/test/io/http_test.dart index a551230958..3f9aad815e 100644 --- a/pkgs/http/test/io/http_test.dart +++ b/pkgs/http/test/io/http_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'package:http/http.dart' as http; import 'package:test/test.dart'; @@ -31,8 +32,7 @@ void main() { test('head runWithClient', () { expect( - () => http.runWithClient( - () => http.head(serverUrl), () => TestClient()), + () => http.runWithClient(() => http.head(serverUrl), TestClient.new), throwsUnimplementedError); }); @@ -59,8 +59,7 @@ void main() { test('get runWithClient', () { expect( - () => - http.runWithClient(() => http.get(serverUrl), () => TestClient()), + () => http.runWithClient(() => http.get(serverUrl), TestClient.new), throwsUnimplementedError); }); @@ -175,7 +174,7 @@ void main() { test('post runWithClient', () { expect( () => http.runWithClient( - () => http.post(serverUrl, body: 'testing'), () => TestClient()), + () => http.post(serverUrl, body: 'testing'), TestClient.new), throwsUnimplementedError); }); @@ -290,7 +289,7 @@ void main() { test('put runWithClient', () { expect( () => http.runWithClient( - () => http.put(serverUrl, body: 'testing'), () => TestClient()), + () => http.put(serverUrl, body: 'testing'), TestClient.new), throwsUnimplementedError); }); @@ -426,7 +425,7 @@ void main() { test('patch runWithClient', () { expect( () => http.runWithClient( - () => http.patch(serverUrl, body: 'testing'), () => TestClient()), + () => http.patch(serverUrl, body: 'testing'), TestClient.new), throwsUnimplementedError); }); @@ -456,8 +455,7 @@ void main() { test('read runWithClient', () { expect( - () => http.runWithClient( - () => http.read(serverUrl), () => TestClient()), + () => http.runWithClient(() => http.read(serverUrl), TestClient.new), throwsUnimplementedError); }); @@ -490,7 +488,7 @@ void main() { test('readBytes runWithClient', () { expect( () => http.runWithClient( - () => http.readBytes(serverUrl), () => TestClient()), + () => http.readBytes(serverUrl), TestClient.new), throwsUnimplementedError); }); }); diff --git a/pkgs/http/test/io/multipart_test.dart b/pkgs/http/test/io/multipart_test.dart index 910fa762ba..3ab90c27cb 100644 --- a/pkgs/http/test/io/multipart_test.dart +++ b/pkgs/http/test/io/multipart_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'dart:io'; diff --git a/pkgs/http/test/io/request_test.dart b/pkgs/http/test/io/request_test.dart index 80a7f24170..ac6b44c3fd 100644 --- a/pkgs/http/test/io/request_test.dart +++ b/pkgs/http/test/io/request_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'package:http/http.dart' as http; import 'package:test/test.dart'; diff --git a/pkgs/http/test/io/streamed_request_test.dart b/pkgs/http/test/io/streamed_request_test.dart index d82006847f..76efd6fe56 100644 --- a/pkgs/http/test/io/streamed_request_test.dart +++ b/pkgs/http/test/io/streamed_request_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'dart:convert'; diff --git a/pkgs/http_client_conformance_tests/CHANGELOG.md b/pkgs/http_client_conformance_tests/CHANGELOG.md deleted file mode 100644 index b78d64c626..0000000000 --- a/pkgs/http_client_conformance_tests/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.0.1 - -- Initial version. diff --git a/pkgs/http_client_conformance_tests/bin/generate_server_wrappers.dart b/pkgs/http_client_conformance_tests/bin/generate_server_wrappers.dart index 912a86f7f7..74f9d00df9 100644 --- a/pkgs/http_client_conformance_tests/bin/generate_server_wrappers.dart +++ b/pkgs/http_client_conformance_tests/bin/generate_server_wrappers.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// Generates the '*_server_vm.dart' and '*_server_web.dart' support files. +library; import 'dart:core'; import 'dart:io'; diff --git a/pkgs/http_client_conformance_tests/example/client_test.dart b/pkgs/http_client_conformance_tests/example/client_test.dart index 749d813872..0b4bbb3089 100644 --- a/pkgs/http_client_conformance_tests/example/client_test.dart +++ b/pkgs/http_client_conformance_tests/example/client_test.dart @@ -12,6 +12,6 @@ class MyHttpClient extends BaseClient { void main() { group('client conformance tests', () { - testAll(() => MyHttpClient()); + testAll(MyHttpClient.new); }); } diff --git a/pkgs/http_client_conformance_tests/pubspec.yaml b/pkgs/http_client_conformance_tests/pubspec.yaml index ef5dc8f81b..6265c08313 100644 --- a/pkgs/http_client_conformance_tests/pubspec.yaml +++ b/pkgs/http_client_conformance_tests/pubspec.yaml @@ -6,13 +6,14 @@ publish_to: none repository: https://github.com/dart-lang/http/tree/master/pkgs/http_client_conformance_tests environment: - sdk: '>=2.14.0 <3.0.0' + sdk: '>=2.19.0 <3.0.0' dependencies: async: ^2.8.2 + dart_style: ^2.2.3 http: ^0.13.4 + stream_channel: ^2.1.1 test: ^1.21.2 dev_dependencies: - dart_style: ^2.2.3 - lints: ^1.0.0 + dart_flutter_team_lints: ^1.0.0