findLyricIndexByDuration method

int findLyricIndexByDuration(
  1. Duration curDuration,
  2. List<Lyric> lyrics
)

Implementation

int findLyricIndexByDuration(Duration curDuration, List<Lyric> lyrics) {
  for (int i = 0; i < lyrics.length; i++) {
    if (curDuration >= lyrics[i].startTime! &&
        curDuration <= lyrics[i].endTime!) {
      return i;
    }
  }
  return 0;
}