0

I want to get the data from Api as a Realtime data , so can I use streambuilder and dart streams with http instead of socket io , and what is the difference

  • You're confusing `HTTP and Websockets` with `Streambuilder`. – nicks101 Jun 03 '22 at 10:31
  • 1
    HTTP is a request oriented service, so you get one request -> one response. If you want a stream of varying results you'd need to make multiple requests (likely inside an `async*` method to produce a stream). You'd likely need to poll the server, perhaps long poll it and `yield` any result that changes. How you do that is an exercise for the reader depending on your needs. The whole point of websockets is to 'improve' on that. See: https://medium.com/geekculture/ajax-polling-vs-long-polling-vs-websockets-vs-server-sent-events-e0d65033c9ba – Richard Heap Jun 03 '22 at 10:58
  • @nicks101 nope , I just wanted to know if it is possible to exchange them with streams via periodic http requests to the server. –  Jun 03 '22 at 11:07
  • @user19022201 You can do it with something like [this](https://stackoverflow.com/a/70951162/9468577). – nicks101 Jun 03 '22 at 16:39

0 Answers0