dispose method Null safety

  1. @mustCallSuper
void dispose()
mustCallSuper">@mustCallSuper

Release the resources used by this object. The object is no longer usable after this method is called.

It is legal to call this method while isActive is true, in which case:

Implementation

@mustCallSuper
void dispose() {
  if (_future != null) {
    final TickerFuture localFuture = _future!;
    _future = null;
    assert(!isActive);
    unscheduleTick();
    localFuture._cancel(this);
  }
  assert(() {
    // We intentionally don't null out _startTime. This means that if start()
    // was ever called, the object is now in a bogus state. This weakly helps
    // catch cases of use-after-dispose.
    _startTime = Duration.zero;
    return true;
  }());
}