delay method

Future delay([
  1. FutureOr callback()?
])

Utility to delay some callback (or code execution).

Sample:

void main() async {
  final _delay = 3.seconds;
  print('+ wait $_delay');
  await _delay.delay();
  print('- finish wait $_delay');
  print('+ callback in 700ms');
  await 0.7.seconds.delay(() {
}

Implementation

Future delay([FutureOr Function()? callback]) async =>
    Future.delayed(this, callback);