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) {
_onDestroy[name] = () {
// Don't return this value because we dont' want to block startup
Future.delayed(wait, destroy);
};
} else {
_onDestroy[name] = destroy;
}
}