dispose method Null safety

  1. @override
void dispose()
override

Frees all the resources used by this performance. After this is called, this object is no longer usable.

Implementation

@override
void dispose() {
  assert(_currentTrain != null);
  _currentTrain!.removeStatusListener(_statusChangeHandler);
  _currentTrain!.removeListener(_valueChangeHandler);
  _currentTrain = null;
  _nextTrain?.removeListener(_valueChangeHandler);
  _nextTrain = null;
  clearListeners();
  clearStatusListeners();
  super.dispose();
}