dispose method Null safety
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:
- The frame callback that was requested by scheduleTick, if any, is canceled.
- The future that was returned by start does not resolve.
- The future obtained from TickerFuture.orCancel, if any, resolves with a TickerCanceled error.
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;
}());
}