onDispose method

  1. @override
void onDispose()
inherited

onDispose is called only once when the widget is disposed from the widget tree, to clean up resources such as streams, timers, and tasks that the ViewModel is holding.

onDispose is equivalent to dispose of StatefulWidget.

Implementation

@override
void onDispose() {
  _cancelViewModelScope();
  _disposeComponent();
  super.onDispose();
}