onDestroy method
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);
}
}