diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b6eea4..7fa75f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## [3.8.1] + +- Added isParseResponseOnBackground flag to ApiClient request params + ## [3.8.0] - Deprecated `onTokensRefreshingFailed()`: This method has been marked as deprecated and will be removed in the next major release. Please resolve errors in `refreshTokens()` using `Future.catchError` instead. diff --git a/example/pubspec.lock b/example/pubspec.lock index 1b99ed1..fbdb603 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -29,10 +29,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -117,10 +117,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" checked_yaml: dependency: transitive description: @@ -149,10 +149,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" convert: dependency: transitive description: @@ -191,7 +191,7 @@ packages: path: ".." relative: true source: path - version: "3.8.0" + version: "3.8.1" dio: dependency: transitive description: @@ -347,10 +347,10 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" json_annotation: dependency: transitive description: @@ -379,10 +379,10 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -395,10 +395,10 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" mime: dependency: transitive description: @@ -419,10 +419,10 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider_linux: dependency: transitive description: @@ -648,10 +648,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" timing: dependency: transitive description: @@ -717,5 +717,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.18.0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=3.0.0" diff --git a/lib/src/api_client.dart b/lib/src/api_client.dart index 412299c..4e95493 100644 --- a/lib/src/api_client.dart +++ b/lib/src/api_client.dart @@ -60,6 +60,7 @@ abstract class ApiClient { Duration? sendTimeout, String contentType = Headers.jsonContentType, CancelToken? cancelToken, + bool isParseResponseOnMainThread = false, }) { return _request(RequestParams( method: HttpMethod.get, @@ -74,6 +75,7 @@ abstract class ApiClient { sendTimeout: sendTimeout, contentType: contentType, cancelToken: cancelToken, + isParseResponseOnMainThread: isParseResponseOnMainThread, )); } @@ -90,6 +92,7 @@ abstract class ApiClient { Duration? sendTimeout, String contentType = Headers.jsonContentType, CancelToken? cancelToken, + bool isParseResponseOnMainThread = false, }) { return _request(RequestParams( method: HttpMethod.post, @@ -106,6 +109,7 @@ abstract class ApiClient { sendTimeout: sendTimeout, contentType: contentType, cancelToken: cancelToken, + isParseResponseOnMainThread: isParseResponseOnMainThread, )); } @@ -122,6 +126,7 @@ abstract class ApiClient { Duration? sendTimeout, String contentType = Headers.jsonContentType, CancelToken? cancelToken, + bool isParseResponseOnMainThread = false, }) { return _request(RequestParams( method: HttpMethod.put, @@ -138,6 +143,7 @@ abstract class ApiClient { sendTimeout: sendTimeout, contentType: contentType, cancelToken: cancelToken, + isParseResponseOnMainThread: isParseResponseOnMainThread, )); } @@ -154,6 +160,7 @@ abstract class ApiClient { Duration? sendTimeout, String contentType = Headers.jsonContentType, CancelToken? cancelToken, + bool isParseResponseOnMainThread = false, }) { return _request(RequestParams( method: HttpMethod.patch, @@ -170,6 +177,7 @@ abstract class ApiClient { sendTimeout: sendTimeout, contentType: contentType, cancelToken: cancelToken, + isParseResponseOnMainThread: isParseResponseOnMainThread, )); } @@ -185,6 +193,7 @@ abstract class ApiClient { Duration? sendTimeout, String contentType = Headers.jsonContentType, CancelToken? cancelToken, + bool isParseResponseOnMainThread = false, }) { return _request(RequestParams( method: HttpMethod.delete, @@ -200,6 +209,7 @@ abstract class ApiClient { sendTimeout: sendTimeout, contentType: contentType, cancelToken: cancelToken, + isParseResponseOnMainThread: isParseResponseOnMainThread, )); } @@ -230,6 +240,10 @@ abstract class ApiClient { final performRequest = (tokenPair) async { final response = await _createRequest(params, tokenPair); + if (params.isParseResponseOnMainThread) { + return params.responseMapper.call(response); + } + return await isolateManager.sendTask( response: response, mapper: params.responseMapper, diff --git a/lib/src/models/request_params.dart b/lib/src/models/request_params.dart index 9e995a3..a5d927f 100644 --- a/lib/src/models/request_params.dart +++ b/lib/src/models/request_params.dart @@ -18,6 +18,7 @@ class RequestParams { this.sendTimeout, this.contentType = Headers.jsonContentType, this.cancelToken, + this.isParseResponseOnMainThread = false, }); final HttpMethod method; @@ -33,4 +34,5 @@ class RequestParams { final Duration? sendTimeout; final String contentType; final CancelToken? cancelToken; + final bool isParseResponseOnMainThread; } diff --git a/pubspec.lock b/pubspec.lock index 2558f77..21db517 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -125,10 +125,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" checked_yaml: dependency: transitive description: @@ -157,10 +157,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.17.1" convert: dependency: transitive description: @@ -404,10 +404,10 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" json_annotation: dependency: transitive description: @@ -436,10 +436,10 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.15" material_color_utilities: dependency: transitive description: @@ -452,10 +452,10 @@ packages: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" mime: dependency: transitive description: @@ -468,10 +468,10 @@ packages: dependency: "direct dev" description: name: mockito - sha256: "2a8a17b82b1bde04d514e75d90d634a0ac23f6cb4991f6098009dd56836aeafe" + sha256: dd61809f04da1838a680926de50a9e87385c1de91c6579629c3d1723946e8059 url: "https://pub.dev" source: hosted - version: "5.3.2" + version: "5.4.0" node_preamble: dependency: transitive description: @@ -492,10 +492,10 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider_linux: dependency: transitive description: @@ -761,26 +761,26 @@ packages: dependency: "direct dev" description: name: test - sha256: a5fcd2d25eeadbb6589e80198a47d6a464ba3e2049da473943b8af9797900c2d + sha256: "3dac9aecf2c3991d09b9cdde4f98ded7b30804a88a0d7e4e7e1678e78d6b97f4" url: "https://pub.dev" source: hosted - version: "1.22.0" + version: "1.24.1" test_api: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.5.1" test_core: dependency: transitive description: name: test_core - sha256: "0ef9755ec6d746951ba0aabe62f874b707690b5ede0fecc818b138fcc9b14888" + sha256: "5138dbffb77b2289ecb12b81c11ba46036590b72a64a7a90d6ffb880f1a29e93" url: "https://pub.dev" source: hosted - version: "0.4.20" + version: "0.5.1" timing: dependency: transitive description: @@ -870,5 +870,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.19.0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index b6fc786..1558cf9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dash_kit_network description: The DashKit plugin that provides basic network functionality including token refresh. -version: 3.8.0 +version: 3.8.1 homepage: https://github.com/Dash-Kit/dash-kit-network environment: