calculateTotalHeight method

void calculateTotalHeight()

calculateTotalHeight

Implementation

void calculateTotalHeight() {
  ///缓存下,避免多余计算
  if (cachePlayingIndex != playingIndex) {
    cachePlayingIndex = playingIndex;
    var lyrics = model?.lyrics ?? [];
    double lastLineSpace = 0;
    //最大偏移量不包含最后一行
    if (lyrics.isNotEmpty) {
      lyrics = lyrics.sublist(0, lyrics.length - 1);
      lastLineSpace = LyricHelper.getLineSpaceHeight(lyrics.last, lyricUI,
          excludeInline: true);
    }
    totalHeight = -LyricHelper.getTotalHeight(lyrics, playingIndex, lyricUI) +
        (model?.firstCenterOffset(playingIndex, lyricUI) ?? 0) -
        (model?.lastCenterOffset(playingIndex, lyricUI) ?? 0) -
        lastLineSpace;
  }
}