play method

void play()

Starts playing the animation.

If the animation is already playing or no asset is loaded, this method has no effect. The playback speed is determined by the fps value in the animation manifest.

Implementation

void play() {
  if (isPlaying || asset == null) return;

  isPlaying = true;
  final frameDuration = Duration(milliseconds: (1000 / asset!.manifest.fps).round());

  _timer = Timer.periodic(frameDuration, (timer) {
    frameIndex = (frameIndex + 1) % asset!.manifest.frames.length;
    notifyListeners();
  });
}