dispose method

  1. @override
void dispose()
override

Cancels timers, disposes the current handle and stops the controller.

Implementation

@override
void dispose() {
  if (_disposed) return;
  _disposed = true;
  // An ad that reached the screen but is torn down before its dismiss event
  // arrives still happened — record it, or the cap under-counts and the next
  // ad could fire too soon.
  _recordImpressionIfPending();
  _timer?.cancel();
  _timer = null;
  _exitCoordinator();
  _dropHandle();
  _finishShow(
    (a) => a.showedOnScreen
        ? AdShowResult.shown(reward: a.reward)
        : const AdShowResult.blocked(AdBlockReason.notReady),
  );
  _state.dispose();
}