onDispose method
void
onDispose()
Disposes all registered effects, cleanup callbacks, and resources.
Iterates through all callbacks registered via addEffect and autoDispose, executing each in order. Disposal is idempotent; subsequent invocations have no effect. Any exceptions thrown by individual disposers are caught and swallowed to guarantee all remaining cleanup callbacks are executed.
controller.onDispose();
print(controller.isDisposed); // true
Implementation
void onDispose() {
if (_isDisposed) return;
_isDisposed = true;
for (final dispose in _disposers) {
try {
dispose();
} catch (_) {
// Best-effort cleanup: swallow errors during disposal
}
}
_disposers.clear();
}