Skip to content

Commit 808da34

Browse files
wilinzwilinz
andauthored
fix: type 'Response' is not a subtype of type 'StreamedResponse' in type cast (#132)
Co-authored-by: wilinz <[email protected]>
1 parent f7f9649 commit 808da34

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/http/intercepted_client.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class InterceptedClient extends BaseClient {
215215

216216
@override
217217
Future<StreamedResponse> send(BaseRequest request) async {
218-
final response = await _attemptRequest(request);
218+
final response = await _attemptRequest(request, isStream: true);
219219

220220
final interceptedResponse = await _interceptResponse(response);
221221

@@ -266,7 +266,8 @@ class InterceptedClient extends BaseClient {
266266

267267
/// Attempts to perform the request and intercept the data
268268
/// of the response
269-
Future<BaseResponse> _attemptRequest(BaseRequest request) async {
269+
Future<BaseResponse> _attemptRequest(BaseRequest request,
270+
{bool isStream = false}) async {
270271
BaseResponse response;
271272
try {
272273
// Intercept request
@@ -278,8 +279,7 @@ class InterceptedClient extends BaseClient {
278279
.send(interceptedRequest)
279280
.timeout(requestTimeout!, onTimeout: onRequestTimeout);
280281

281-
response =
282-
request is Request ? await Response.fromStream(stream) : stream;
282+
response = isStream ? stream : await Response.fromStream(stream);
283283

284284
if (retryPolicy != null &&
285285
retryPolicy!.maxRetryAttempts > _retryCount &&

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ environment:
1111
sdk: ">=3.0.3 <4.0.0"
1212

1313
dependencies:
14-
http: ^1.0.0
14+
http: ^1.1.0
1515

1616
dev_dependencies:
1717
lints: ^2.1.1

0 commit comments

Comments
 (0)