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

Stream.fromIterable bad state already been listened #1165

Closed
dalton5 opened this issue May 22, 2021 · 1 comment
Closed

Stream.fromIterable bad state already been listened #1165

dalton5 opened this issue May 22, 2021 · 1 comment

Comments

@dalton5
Copy link

dalton5 commented May 22, 2021

Hi,

I have an issue. I follow the example exactly as explained in the example file for post bytes.

I use dio 4.0.0

But I always have the error below:

image

My code is:

    ` var content = json.encode(queryParameters);
      List<int> bodyBytes = utf8.encode(content);
      
      var resp = await dio.post(
        endpoint,
        data: Stream.fromIterable(
            bodyBytes.map((e) => [e])), //create a Stream<List<int>>
        options: Options(
          headers: {
            Headers.contentLengthHeader:
                bodyBytes.length, // set content-length
          },
        ),
      );`

Stacktrace:

#0 _GeneratedStreamImpl._createSubscription (dart:async/stream_impl.dart:505:18)
#1 _StreamImpl.listen (dart:async/stream_impl.dart:473:9)
#2 new _SinkTransformerStreamSubscription (dart:async/stream_transformers.dart:49:16)
#3 _BoundSinkStream.listen (dart:async/stream_transformers.dart:171:9)
#4 _HttpOutgoing.addStream (dart:_http/http_impl.dart:1555:22)
#5 _StreamSinkImpl.addStream.targetAddStream (dart:_http/http_impl.dart:652:22)
#6 _StreamSinkImpl.addStream (dart:_http/http_impl.dart:658:51)
#7 _HttpOutboundMessage.addStream (dart:_http/http_impl.dart:871:20)
#8 DefaultHttpClientAdapter.fetch (package:dio/src/adapters/io_adapter.dart:70:21)

#9 DioMixin._dispatchRequest (package:dio/src/dio_mixin.dart:632:22)

#10 DioMixin.fetch.. (package:dio/src/dio_mixin.dart)

@stale
Copy link

stale bot commented Jun 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions.

@stale stale bot added the stale label Jun 22, 2021
@stale stale bot closed this as completed Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant