Skip to content
DeveloperMemos

Run Code After a Delay With Flutter

Flutter, Futures1 min read

If you're wondering how to run some code after a delay with Flutter/Dart it's actually pretty simple. You're probably looking for something similar to Handler.postDelayed if you're an Android developer. Dart's Future.delayed does pretty much the exact same thing.

Here's a quick example of how to use it:

1Future.delayed(Duration(milliseconds: 600), () {
2 // Code to execute
3});

Or even:

1Future.delayed(Duration(milliseconds: 600), () {
2 Navigator.of(context).pushReplacementNamed("/");
3});