Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dio): Allow ResponseDecoder and RequestEncoder to be async #2015

Merged
merged 10 commits into from
Nov 10, 2023
4 changes: 3 additions & 1 deletion dio/lib/src/options.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:meta/meta.dart';

import 'adapter.dart';
Expand Down Expand Up @@ -76,7 +78,7 @@ enum ListFormat {
typedef ValidateStatus = bool Function(int? status);

/// The type of a response decoding callback.
typedef ResponseDecoder = String? Function(
typedef ResponseDecoder = FutureOr<String?> Function(
List<int> responseBytes,
RequestOptions options,
ResponseBody responseBody,
Expand Down
2 changes: 1 addition & 1 deletion dio/lib/src/transformers/sync_transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class SyncTransformer extends Transformer {
);
final String? response;
if (options.responseDecoder != null) {
response = options.responseDecoder!(
response = await options.responseDecoder!(
Reprevise marked this conversation as resolved.
Show resolved Hide resolved
responseBytes,
options,
responseBody..stream = Stream.empty(),
Expand Down