dio icon indicating copy to clipboard operation
dio copied to clipboard

Make ResponseDecoder return nullable String type since the usage is r…

Open huhx opened this issue 2 years ago • 0 comments

This PR make the ResponseDecoder return nullable String

In options.dart:

typedef ResponseDecoder = String Function(
    List<int> responseBytes, RequestOptions options, ResponseBody responseBody);

The usage of this function: src/transformer.dart

String? responseBody;
if (options.responseDecoder != null) {
  responseBody = options.responseDecoder!(
    responseBytes,
    options,
    response..stream = Stream.empty(),
  );
} else {
  responseBody = utf8.decode(responseBytes, allowMalformed: true);
}

As we can see the responseBody is nullable, it means ResponseDecoder function return String? may be make sense.

huhx avatar Apr 01 '22 01:04 huhx