sleep function

Future<void> sleep(
  1. int seconds, [
  2. int microseconds = 0
])

Delays execution for the specified duration.

Parameters: seconds: Integer seconds to sleep (backward compatible usage) microseconds: Optional microseconds to sleep

Examples: await sleep(2); // Sleeps for 2 seconds await sleep(0, 500); // Sleeps for 500 microseconds await sleep(1, 500000); // Sleeps for 1.5 seconds

Implementation

Future<void> sleep(int seconds, [int microseconds = 0]) async {
  await Future.delayed(Duration(
    seconds: seconds,
    microseconds: microseconds,
  ));
}