From 408f44cc66ab33e9cacc6276627d84969d5d0e4e Mon Sep 17 00:00:00 2001 From: Dusty Holmes Date: Fri, 1 Mar 2024 11:49:04 -0600 Subject: [PATCH] Revert "Ensure all child modules get unloaded" --- lib/src/lifecycle_module.dart | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/src/lifecycle_module.dart b/lib/src/lifecycle_module.dart index b37e0e0..217e7c9 100644 --- a/lib/src/lifecycle_module.dart +++ b/lib/src/lifecycle_module.dart @@ -1124,20 +1124,12 @@ abstract class LifecycleModule extends SimpleModule with Disposable { _activeSpan = _startTransitionSpan('unload'); _willUnloadController.add(this); - - // We're looping here because it's possible for additional child modules to be added to this list while we are - // unloading the current items. While loadChildModule is guarded from adding new modules after unload starts, - // it contains asynchronous elements that allow a module to be added to this list during the unload. - // Note that items get removed from this list by an event handler listening to their didDispose stream. - while (_childModules.isNotEmpty) { - await Future.wait(_childModules.toList().map((child) { - child.parentContext = _activeSpan?.context; - return child.unload().whenComplete(() { - child.parentContext = null; - }); - })); - } - + await Future.wait(_childModules.toList().map((child) { + child.parentContext = _activeSpan?.context; + return child.unload().whenComplete(() { + child.parentContext = null; + }); + })); try { await onUnload(); } catch (error, stackTrace) {