wait static method

Future<void> wait(
  1. int milliseconds
)

Allows you to pause instructions for a set time.

await Future.delayed(Duration(milliseconds: milliseconds), () {});

EXAMPLE:

Once the state has changed, wait for the animation to finish, which will last 400 milliseconds and then close the context

  setState(() => showWidget = false);
  await Misc.wait(400);
  Navigator.pop(context);

Implementation

static Future<void> wait(int milliseconds) async {
  await Future.delayed(Duration(milliseconds: milliseconds), () {});
}