dispose method

  1. @override
void dispose()
override

Disposes this LiveData and cleans up all resources.

Clears all subscribers, disposes the internal scope, and removes this LiveData from its parentScope. After calling dispose, this LiveData should not be used anymore.

The ViewModel automatically disposes all LiveData instances registered in its scope, so manual disposal is usually not needed.

Implementation

@override
void dispose() {
  _isDisposed = true;
  _subscribers.clear();
  scope?.dispose();
  parentScope?.remove(this);
  super.dispose();
}