onDestroy method

void onDestroy(
  1. String name,
  2. LifecycleCallback destroy, {
  3. Duration? wait,
})

Implementation

void onDestroy(String name, LifecycleCallback destroy, {Duration? wait}) {
  // if (_onDestroy.containsKey(name)) {
  //   throw "Initializer $name already exists for $runtimeType";
  // }
  if (wait != null) {
    onShutdown(() async {
      // Don't return this value because we dont' want to block startup
      Future.delayed(wait, destroy);
    });
  } else {
    onShutdown(() async => destroy);
  }
}