disposeBooted static method
void
disposeBooted()
Undo what bootProviders and the providers' own boot() left behind
that Magic.flush() does not reach.
- Controllers are disposed, newest first so dependents go before what
they depend on.
Magic.flush()only drops them from the registry, and a controller holding a timer or a stream subscription outlives the test and fires into the next file. - SessionScope stops listening to auth state; its subscription is a process static.
- MagicRouter drops its routes and observers, also a process static.
- The container is flushed last, so a controller's
dispose()can still resolve what it needs.
A controller a test already disposed itself is safe when it is a
MagicController; a plain ChangeNotifier throws on a second dispose.
Implementation
static void disposeBooted() {
for (final controller in Magic.controllers.toList().reversed) {
if (controller is ChangeNotifier) {
controller.dispose();
}
}
SessionScope.detach();
MagicRouter.reset();
Magic.flush();
}