Dart: convert Observable to Future and vice-versa?

Issue

How can I convert a Dart Observable to a Future and vice-versa?

Solution

To convert a Observable to a Future:

  • myObservable.first
  • myObservable.firstWhere

To convert a Future to an Observable:

  • Observable.fromFuture(myFuture)

Or into a simple stream:

  • myFuture.asStream()

Answered By – Daniel Oliveira

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.