You can do it in two ways 1 is Future.delayed
and 2 is Timer
Using Timer
Timer
is a class that represents a count-down timer that is configured to trigger an action once end of time is reached, and it can fire once or repeatedly.
Make sure to import dart:async
package to start of program to use Timer
Timer(Duration(seconds: 5), () {
print(" This line is execute after 5 seconds");
});
Using Future.delayed
Future.delayed
is creates a future that runs its computation after a delay.
Make sure to import "dart:async";
package to start of program to use Future.delayed
Future.delayed(Duration(seconds: 5), () {
print(" This line is execute after 5 seconds");
});