Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dart, why doesn't Timer.run() return a Future?

Why doesn't Timer.run() return a Future? I am running some code inside the run() call which may throw an exception and if it doesn't return a future how can I add a catchError() on to it?

like image 690
Daniel Robinson Avatar asked Apr 24 '26 10:04

Daniel Robinson


1 Answers

Why not use Future.delayed for this use case? This would give you a future that completes after a certain period of time. I'm guessing that's what you're trying to achieve by putting your code inside Timer.run.

You can find an example of how to use Future.delayed here.

You may also find Dart docs about Future useful.

like image 93
markovuksanovic Avatar answered Apr 26 '26 22:04

markovuksanovic