From 4b1f1ec6ee04b006ffb7c8ac11ee7b30978acbe6 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 14 Dec 2023 17:12:50 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Mark=20`DioMixin`'s=20todo?= =?UTF-8?q?=20and=20add=20tests=20(#2066)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `DioMixin` was never a real mixin before. Marking it to use `mixin class` once we use `>=3.0.0` as the SDK constraint. ### New Pull Request Checklist - [x] I have read the [Documentation](https://pub.dev/documentation/dio/latest/) - [x] I have searched for a similar pull request in the [project](https://github.com/cfug/dio/pulls) and found none - [x] I have updated this branch with the latest `main` branch to avoid conflicts (via merge from master or rebase) - [x] I have added the required tests to prove the fix/feature I'm adding - [x] I have updated the documentation (if necessary) - [x] I have run the tests without failures - [ ] I have updated the `CHANGELOG.md` in the corresponding package ### Additional context and info (if any) The following exception will be raised if we roll the lower bound of the package to ^3.0.0: `The class 'DioMixin' can't be used as a mixin because it's neither a mixin class nor a mixin.` --- dio/lib/src/dio_mixin.dart | 1 + dio/test/dio_mixin_test.dart | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/dio/lib/src/dio_mixin.dart b/dio/lib/src/dio_mixin.dart index 97d23c641..b3bbaabbe 100644 --- a/dio/lib/src/dio_mixin.dart +++ b/dio/lib/src/dio_mixin.dart @@ -23,6 +23,7 @@ import 'progress_stream/io_progress_stream.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 { /// The base request config for the instance. @override diff --git a/dio/test/dio_mixin_test.dart b/dio/test/dio_mixin_test.dart index 9468618bd..5d97cb5f1 100644 --- a/dio/test/dio_mixin_test.dart +++ b/dio/test/dio_mixin_test.dart @@ -2,6 +2,11 @@ import 'package:dio/dio.dart'; import 'package:test/test.dart'; void main() { + test('not thrown for implements', () { + expect(_TestDioMixin().interceptors, isA()); + expect(_TestDioMixinExtends().interceptors, isA()); + }); + test('assureResponse', () { final requestOptions = RequestOptions(path: ''); final untypedResponse = Response( @@ -26,3 +31,5 @@ void main() { } class _TestDioMixin with DioMixin implements Dio {} + +class _TestDioMixinExtends extends DioMixin implements Dio {}