dispose method

  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() {
  // TODO(polina-c): stop duplicating code across disposables
  // https://github.com/flutter/flutter/issues/137435
  if (kFlutterMemoryAllocationsEnabled) {
    FlutterMemoryAllocations.instance.dispatchObjectDisposed(object: this);
  }
  assert(_currentTrain != null);
  _currentTrain!.removeStatusListener(_statusChangeHandler);
  _currentTrain!.removeListener(_valueChangeHandler);
  _currentTrain = null;
  _nextTrain?.removeListener(_valueChangeHandler);
  _nextTrain = null;
  clearListeners();
  clearStatusListeners();
  super.dispose();
}