sleep function

Future<void> sleep(
  1. SleepOptions options
)

Suspends the execution of the current isolate for the specified options.ms milliseconds.

Returns a Future that completes after the specified duration.

Example usage:

await sleep(SleepOptions(ms: 2000));
print("Waited for 2 seconds");

Implementation

Future<void> sleep(SleepOptions options) {
  return Future.delayed(Duration(milliseconds: options.ms));
}