computeScrollY method

double computeScrollY (
  1. int curLine
)

计算传入行和第一行的偏移量

Implementation

double computeScrollY(int curLine) {
  double totalHeight = 0;
  for (var i = 0; i < curLine; i++) {
    var currPaint = lyricTextPaints[i];
    currPaint.layout(maxWidth: lyricMaxWidth);
    totalHeight += currPaint.height + lyricGapValue;
  }
  if (subLyrics != null) {
    //增加 当前行之前的翻译歌词的偏移量
    var list = subLyrics
        .where((subLyric) => subLyric.endTime <= lyrics[curLine].endTime)
        .toList();
    totalHeight += list.length * (subLyricGapValue + _subLyricHeight);
  }
  return totalHeight;
}