playOnce method

Future playOnce(
  1. Future<SpriteAnimation> animation, {
  2. VoidCallback? onFinish,
  3. bool runToTheEnd = false,
})

Method used to play animation once time

Implementation

Future playOnce(
  Future<SpriteAnimation> animation, {
  VoidCallback? onFinish,
  bool runToTheEnd = false,
}) async {
  if (position != null) {
    runToTheEndFastAnimation = runToTheEnd;
    final anim = AnimatedObjectOnce(
      position: position!,
      animation: animation,
      onFinish: () {
        onFinish?.call();
        _fastAnimation = null;
      },
    );
    await anim.onLoad();
    _fastAnimation = anim;
  }
}