This is common in other languages. setTimeout(fn, 0)
in JavaScript, and DispatchQueue.main.async() {}
in Swift.
How best to do this in Flutter?
I have used Future.delayed(Duration.zero).then(fn)
, but I don't like it because like JS's setTimeout
and unlike swifts DispatchQueue.main.async() {}
it doesn't really express the intent, only the behaviour. Is there a way of doing this that is the correct way to do this in Flutter.