dispose method

  1. @override
void dispose()
override

Frees up resources and cancels any pending operations, preparing this instance for removal from memory.

Call this method when the object is no longer needed to ensure that any resources are released as soon as possible. Once this method is called, the behavior of accessing the object is undefined and should be avoided.

This method also stops any ongoing animations and removes all listeners from the onFramesComplete signal. It resets the frame count and accumulated time to zero and sets the _frameTextures list to null.

Implementation

@override
void dispose() {
  super.dispose();
  playing = false;
  frameCount = 0;
  accumulatedTime = 0;
  _onFramesComplete?.removeAll();
  _frameTextures = null;
}