findCurrent static method

SoundAnimation? findCurrent(
  1. List<Animation> animations,
  2. double prevScroll,
  3. double scroll
)

Поиск текущей звуковой анимации

Implementation

static SoundAnimation? findCurrent(
  List<Animation> animations,
  double prevScroll,
  double scroll,
) {
  try {
    return animations.whereType<SoundAnimation>().firstWhere(
      (x) =>
          (x.start <= scroll && x.end >= scroll) ||
          (x.start == x.end &&
              prevScroll < scroll &&
              prevScroll <= x.start &&
              x.start <= scroll),
    );
  } catch (e) {
    return null;
  }
}