dispose method
void
dispose()
Disposes this ref, releasing all subscribers.
After disposal, any attempt to read or write the ref will throw a StateError. Subscribers are notified of removal via Subscriber.onDependencyRemoved.
When to Dispose
Dispose refs when they're no longer needed to prevent memory leaks, especially for refs created within components.
Implementation
void dispose() {
if (_disposed) return;
_disposed = true;
// Notify all subscribers that this dependency is gone
for (final subscriber in _subscribers.toList()) {
subscriber.onDependencyRemoved(this);
}
_subscribers.clear();
}