Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 #v2.23.0
with:
cache: true
flutter-version: ${{ case(matrix.sdk == 'min', '3.3.0', '') }}
flutter-version: ${{ case(matrix.sdk == 'min', '3.19.0', '') }}
channel: ${{ case(matrix.sdk == 'min', '', matrix.channel) }}
- run: |
echo "TARGET_DART_SDK=$TARGET_DART_SDK" >> $GITHUB_ENV
Expand All @@ -55,10 +55,7 @@ jobs:
- uses: bluefireteam/melos-action@2982f8e4fc92440a219490009d6d05195cb1a6a5 #v3.8.0
with:
run-bootstrap: false
melos-version: ${{ case(matrix.sdk == 'min', '3.4.0', '^6.0.0') }}
- name: Remove dio_web_adapter overrides
if: ${{ matrix.sdk == 'min' }}
run: rm -rf plugins/web_adapter
melos-version: ^6.0.0
- name: Check satisfied packages
run: |
dart ./scripts/melos_packages.dart
Expand Down
3 changes: 2 additions & 1 deletion dio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ See the [Migration Guide][] for the complete breaking changes list.**

## Unreleased

*None.*
- Raise minimum Dart SDK version to 3.3.0 and `dio_web_adapter` constraint to `^2.0.0`.
- Remove legacy `dart.library.html` conditional imports and simplify `kIsWeb` check to `dart.library.js_interop`.

## 5.11.1

Expand Down
5 changes: 2 additions & 3 deletions dio/lib/src/adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import 'dart:typed_data';
import 'package:meta/meta.dart';

import 'adapters/io_adapter.dart'
if (dart.library.js_interop) 'adapters/browser_adapter.dart'
if (dart.library.html) 'adapters/browser_adapter.dart' as adapter;
if (dart.library.js_interop) 'adapters/browser_adapter.dart' as adapter;
import 'headers.dart';
import 'options.dart';
import 'redirect_record.dart';
Expand All @@ -22,7 +21,7 @@ import 'redirect_record.dart';
///
/// If you want to customize the [HttpClientAdapter] you should instead use
/// either [IOHttpClientAdapter] on `dart:io` platforms
/// or [BrowserHttpClientAdapter] on `dart:html` platforms.
/// or [BrowserHttpClientAdapter] on web platforms.
/// {@endtemplate}
abstract class HttpClientAdapter {
/// Create a [HttpClientAdapter] based on the current platform (IO/Web).
Expand Down
4 changes: 1 addition & 3 deletions dio/lib/src/compute/compute.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

import 'dart:async';

import 'compute_io.dart'
if (dart.library.js_interop) 'compute_web.dart'
if (dart.library.html) 'compute_web.dart' as _c;
import 'compute_io.dart' if (dart.library.js_interop) 'compute_web.dart' as _c;

/// Signature for the callback passed to [compute].
///
Expand Down
3 changes: 1 addition & 2 deletions dio/lib/src/dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import 'dart:async';
import 'adapter.dart';
import 'cancel_token.dart';
import 'dio/dio_for_native.dart'
if (dart.library.js_interop) 'dio/dio_for_browser.dart'
if (dart.library.html) 'dio/dio_for_browser.dart';
if (dart.library.js_interop) 'dio/dio_for_browser.dart';
import 'dio_mixin.dart';
import 'headers.dart';
import 'options.dart';
Expand Down
6 changes: 2 additions & 4 deletions dio/lib/src/dio_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ import 'headers.dart';
import 'interceptors/imply_content_type.dart';
import 'options.dart';
import 'progress_stream/io_progress_stream.dart'
if (dart.library.js_interop) 'progress_stream/browser_progress_stream.dart'
if (dart.library.html) 'progress_stream/browser_progress_stream.dart';
if (dart.library.js_interop) 'progress_stream/browser_progress_stream.dart';
import 'response.dart';
import 'response/response_stream_handler.dart';
import 'transformer.dart';

part 'interceptor.dart';

// TODO(EVERYONE): Use `mixin class` when the lower bound of SDK is raised to 3.0.0.
abstract class DioMixin implements Dio {
abstract mixin class DioMixin implements Dio {
/// The base request config for the instance.
@override
late BaseOptions options;
Expand Down
3 changes: 1 addition & 2 deletions dio/lib/src/multipart_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import 'package:http_parser/http_parser.dart' show MediaType;
import 'package:mime/mime.dart' show lookupMimeType;

import 'multipart_file/io_multipart_file.dart'
if (dart.library.js_interop) 'multipart_file/browser_multipart_file.dart'
if (dart.library.html) 'multipart_file/browser_multipart_file.dart';
if (dart.library.js_interop) 'multipart_file/browser_multipart_file.dart';
import 'utils.dart';

/// The type (alias) for specifying the content-type of the `MultipartFile`.
Expand Down
4 changes: 1 addition & 3 deletions dio/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import 'options.dart';
import 'parameter.dart';

// See https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/foundation/constants.dart.
const _kIsWebInterop = bool.fromEnvironment('dart.library.js_interop');
const _kIsWebUtil = bool.fromEnvironment('dart.library.js_util');
const kIsWeb = _kIsWebInterop || _kIsWebUtil || identical(0, 0.0);
const kIsWeb = bool.fromEnvironment('dart.library.js_interop');

// For the web platform, an inline `bool.fromEnvironment` translates to
// `core.bool.fromEnvironment` instead of correctly being replaced by the
Expand Down
4 changes: 2 additions & 2 deletions dio/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repository: https://github.com/cfug/dio/blob/main/dio
issue_tracker: https://github.com/cfug/dio/issues

environment:
sdk: '>=2.18.0 <4.0.0'
sdk: ^3.3.0

dependencies:
async: ^2.8.2
Expand All @@ -27,7 +27,7 @@ dependencies:
mime: '>=1.0.0 <3.0.0'
path: ^1.8.0

dio_web_adapter: '>=1.1.0 <3.0.0'
dio_web_adapter: ^2.0.0

dev_dependencies:
lints: any
Expand Down
19 changes: 0 additions & 19 deletions dio/test/interceptor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,53 +113,44 @@ void main() {
switch (reqOpt.path) {
case '/resolve':
handler.resolve(Response(requestOptions: reqOpt, data: 1));
break;
case '/resolve-next':
handler.resolve(
Response(requestOptions: reqOpt, data: 2),
true,
);
break;
case '/resolve-next/always':
handler.resolve(
Response(requestOptions: reqOpt, data: 2),
true,
);
break;
case '/resolve-next/reject':
handler.resolve(
Response(requestOptions: reqOpt, data: 2),
true,
);
break;
case '/resolve-next/reject-next':
handler.resolve(
Response(requestOptions: reqOpt, data: 2),
true,
);
break;
case '/reject':
handler
.reject(DioException(requestOptions: reqOpt, error: 3));
break;
case '/reject-next':
handler.reject(
DioException(requestOptions: reqOpt, error: 4),
true,
);
break;
case '/reject-next/reject':
handler.reject(
DioException(requestOptions: reqOpt, error: 5),
true,
);
break;
case '/reject-next-response':
handler.reject(
DioException(requestOptions: reqOpt, error: 5),
true,
);
break;
default:
handler.next(reqOpt); //continue
}
Expand All @@ -172,25 +163,21 @@ void main() {
case '/resolve-next':
response.data++;
handler.resolve(response); //3
break;
case '/resolve-next/always':
response.data++;
handler.next(response); //3
break;
case '/resolve-next/reject':
handler.reject(
DioException(
requestOptions: options,
error: '/resolve-next/reject',
),
);
break;
case '/resolve-next/reject-next':
handler.reject(
DioException(requestOptions: options, error: ''),
true,
);
break;
default:
handler.next(response); //continue
}
Expand Down Expand Up @@ -227,7 +214,6 @@ void main() {
case '/resolve-next/always':
response.data++;
handler.next(response); //4
break;
default:
handler.next(response); //continue
}
Expand Down Expand Up @@ -337,35 +323,30 @@ void main() {
data: 'fake data',
),
);
break;
case '/fakepath2':
dio
.get('/test')
.then(handler.resolve)
.catchError((e) => handler.reject(e as DioException));
break;
case '/fakepath3':
handler.reject(
DioException(
requestOptions: options,
error: 'test error',
),
);
break;
case '/fakepath4':
handler.reject(
DioException(
requestOptions: options,
error: 'test error',
),
);
break;
case '/test?tag=1':
dio.get('/token').then((response) {
options.headers['token'] = response.data['data']['token'];
handler.next(options);
});
break;
default:
handler.next(options); //continue
}
Expand Down
10 changes: 0 additions & 10 deletions dio/test/transformer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,10 @@ void main() {
case ResponseType.json:
case ResponseType.plain:
expect(response, '');
break;
case ResponseType.stream:
expect(response, isA<ResponseBody>());
break;
case ResponseType.bytes:
expect(response, []);
break;
default:
throw AssertionError('Unknown response type: $responseType');
}
}
final jsonResponse = await transformer.transformResponse(
Expand Down Expand Up @@ -360,15 +355,10 @@ void main() {
case ResponseType.json:
case ResponseType.plain:
expect(response, '');
break;
case ResponseType.stream:
expect(response, isA<ResponseBody>());
break;
case ResponseType.bytes:
expect(response, []);
break;
default:
throw AssertionError('Unknown response type: $responseType');
}
}
final jsonResponse = await transformer.transformResponse(
Expand Down
4 changes: 1 addition & 3 deletions dio_test/lib/src/utils.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const _kIsWebInterop = bool.fromEnvironment('dart.library.js_interop');
const _kIsWebUtil = bool.fromEnvironment('dart.library.js_util');
const kIsWeb = _kIsWebInterop || _kIsWebUtil || identical(0, 0.0);
const kIsWeb = bool.fromEnvironment('dart.library.js_interop');

const nonRoutableUrl = 'http://10.0.0.0';

Expand Down
2 changes: 1 addition & 1 deletion dio_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: https://github.com/cfug/dio/blob/main/dio_test
issue_tracker: https://github.com/cfug/dio/issues

environment:
sdk: '>=2.18.0 <4.0.0'
sdk: ^3.3.0

dependencies:
dio: any
Expand Down
2 changes: 1 addition & 1 deletion example_dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.0.1
publish_to: "none"

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ^3.3.0

dependencies:
cookie_jar:
Expand Down
2 changes: 1 addition & 1 deletion example_flutter_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Demonstrates how to use the dio package.
publish_to: 'none'

environment:
sdk: ">=2.18.0 <4.0.0"
sdk: ^3.3.0

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion plugins/compatibility_layer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

*None.*
- Bump minimum Dart SDK version to 3.3.0 and simplify web platform check to `dart.library.js_interop`.

## 0.1.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import 'dart:typed_data';
import 'package:dio/dio.dart';
import 'package:http/http.dart' as http;

const _kIsWebInterop = bool.fromEnvironment('dart.library.js_interop');
const _kIsWebUtil = bool.fromEnvironment('dart.library.js_util');
const _kIsWeb = _kIsWebInterop || _kIsWebUtil || identical(0, 0.0);
const _kIsWeb = bool.fromEnvironment('dart.library.js_interop');

/// A conversion layer which translates [Dio] requests to
/// [`http`](https://pub.dev/packages/http) compatible requests.
Expand Down
2 changes: 1 addition & 1 deletion plugins/compatibility_layer/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository: https://github.com/cfug/dio/blob/main/plugins/compatibility_layer
issue_tracker: https://github.com/cfug/dio/issues

environment:
sdk: ^3.0.0
sdk: ^3.3.0

dependencies:
dio: ^5.2.0
Expand Down
2 changes: 1 addition & 1 deletion plugins/cookie_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

*None.*
- Bump minimum Dart SDK version to 3.3.0 and simplify web platform check to `dart.library.js_interop`.

## 3.5.0

Expand Down
4 changes: 1 addition & 3 deletions plugins/cookie_manager/lib/src/cookie_mgr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import 'package:dio/dio.dart';

import 'exception.dart';

const _kIsWebInterop = bool.fromEnvironment('dart.library.js_interop');
const _kIsWebUtil = bool.fromEnvironment('dart.library.js_util');
const _kIsWeb = _kIsWebInterop || _kIsWebUtil || identical(0, 0.0);
const _kIsWeb = bool.fromEnvironment('dart.library.js_interop');

/// - `(?<=)` is a positive lookbehind assertion that matches a comma (",")
/// only if it's preceded by a specific pattern. In this case, the lookbehind
Expand Down
2 changes: 1 addition & 1 deletion plugins/cookie_manager/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repository: https://github.com/cfug/dio/blob/main/plugins/cookie_manager
issue_tracker: https://github.com/cfug/dio/issues

environment:
sdk: ">=2.18.0 <4.0.0"
sdk: ^3.3.0

dependencies:
cookie_jar: ^4.0.0
Expand Down
2 changes: 1 addition & 1 deletion plugins/http2_adapter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ See the [Migration Guide][] for the complete breaking changes list.**

## Unreleased

*None.*
- Bump minimum Dart SDK version to 3.3.0.

## 2.9.0

Expand Down
2 changes: 1 addition & 1 deletion plugins/http2_adapter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository: https://github.com/cfug/dio/blob/main/plugins/http2_adapter
issue_tracker: https://github.com/cfug/dio/issues

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ^3.3.0

dependencies:
dio: ^5.2.0
Expand Down
Loading