Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a Future in flutter to a Stream

I have a function that returns a Future of the type duration.

Future loadur(TimerService timerservice) async {
 var dur = Duration.zero;
 dur = await timerservice.currentDuration();
 return dur;}

The future takes duration from a timerservice which updates itself to run a timer.Now i want the future to be converted to a stream so i can show it in a StreamBuilder(Futurebuilder doesn't update the timer).

Any way to convert the future to a stream of duration will be helpful.

like image 960
ganraj kelkar Avatar asked Nov 14 '18 05:11

ganraj kelkar


1 Answers

you can Use Stream.fromFuture(dur)

like image 108
Mohammed Mahmoud Avatar answered Oct 07 '22 14:10

Mohammed Mahmoud