0

I have POST and GET request endpoints that I'm consuming in my Flutter application. Then from the backend, values could get updated. For instance, a transaction goes from pending to successful. So how could I make that Future response behave like a stream that it updates in real-time and reflect in the UI?

nifesi
  • 80
  • 7
  • check https://docs.flutter.dev/cookbook/networking/web-sockets#2-listen-for-messages-from-the-server – pskink Oct 21 '22 at 18:11
  • If you only have a GET endpoint you can't detect changes, unless you request the same thing again and compare the results (aka polling). (Other technologies exist like websockets where you can receive updates as things change.) You *could* poll the server in an `async*` function and `yield` values that are different from the previous request, but that may not be appropriate. – Richard Heap Oct 21 '22 at 18:57

1 Answers1

-1

you could use getx for this when you recieve data from api u can store it in rx eg var name = "abc".obs; variable and whereever you want to display it just use Obx(()=>Text(name .value))

https://pub.dev/packages/get

Farhan
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 24 '22 at 14:22