Skip to content

Commit

Permalink
core: update code for dio 4.0.0-prev3
Browse files Browse the repository at this point in the history
  • Loading branch information
llfbandit committed Mar 20, 2021
1 parent f48d105 commit 2689ffe
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## 2.0.0-rc.2
- core: Update dio to 4.0.0-prev2.
- core: Update dio to 4.0.0-prev3.
- Renamed `cacheStoreForce` to `forceCache`.
- Renamed `cacheStoreNo` to `noCache`.
- Make `CacheOptions.store` required but still with optional value.
Expand Down
8 changes: 4 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _MyAppState extends State<MyApp> {
child: Text('Call (Refresh policy)'),
),
RaisedButton(
onPressed: () async => await _cacheStoreNoCall(),
onPressed: () async => await _noCacheCall(),
child: Text('Call (Cache no store policy)'),
),
Text(text),
Expand All @@ -90,8 +90,8 @@ class _MyAppState extends State<MyApp> {
);
}

Future _cacheStoreNoCall() async {
final resp = await _call(policy: CachePolicy.cacheStoreNo);
Future _noCacheCall() async {
final resp = await _call(policy: CachePolicy.noCache);
if (resp == null) return;
setState(() => text = _getResponseContent(resp));
}
Expand Down Expand Up @@ -152,7 +152,7 @@ class _MyAppState extends State<MyApp> {
buffer.writeln('Call returned ${response.statusCode}\n');

buffer.writeln('Request headers:');
buffer.writeln('${response.request.headers.toString()}\n');
buffer.writeln('${response.requestOptions.headers.toString()}\n');

buffer.writeln('Response headers (cache related):');
if (date != null) {
Expand Down
2 changes: 0 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ dependencies:
path_provider: ^2.0.0
sqlite3_flutter_libs: ^0.4.0+1

cupertino_icons: ^0.1.3

# The following section is specific to Flutter.
flutter:
uses-material-design: true
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ description: Dio HTTP cache interceptor with multiple stores respecting HTTP dir
repository: https://github.com/llfbandit/dio_cache_interceptor
issue_tracker: https://github.com/llfbandit/dio_cache_interceptor/issues

version: 2.0.0-rc.1
version: 2.0.0-rc.2

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
# https://pub.dev/packages/dio
dio: ^4.0.0-prev2
dio: ^4.0.0-prev3
# https://pub.dev/packages/moor
moor: ^4.1.0
# https://pub.dev/packages/path
Expand Down
11 changes: 2 additions & 9 deletions test/cache_interceptor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,9 @@ void main() {

test('Fetch canceled', () async {
try {
final ct = CancelToken();
// ignore: unawaited_futures
Future.delayed(const Duration(milliseconds: 200)).then(
(value) => ct.cancel(),
);

// cancel waits for 400 milli seconds
await _dio.get(
'${MockHttpClientAdapter.mockBase}/cancel',
cancelToken: ct,
'${MockHttpClientAdapter.mockBase}/ok',
cancelToken: CancelToken()..cancel(),
);
} catch (err) {
expect(err is DioError, isTrue);
Expand Down
9 changes: 0 additions & 9 deletions test/mock_httpclient_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ class MockHttpClientAdapter extends HttpClientAdapter {
Headers.contentTypeHeader: [Headers.jsonContentType]
},
);
case '/cancel':
await Future.delayed(const Duration(milliseconds: 400));
return ResponseBody.fromString(
jsonEncode({'path': uri.path}),
200,
headers: {
Headers.contentTypeHeader: [Headers.jsonContentType]
},
);
case '/exception':
if (options.extra.containsKey('x-err')) {
throw DioError(
Expand Down

0 comments on commit 2689ffe

Please sign in to comment.