generateAudioBars method

List<AudioBar> generateAudioBars(
  1. List<double> listOfHeights,
  2. Color playedColor,
  3. Color unplayedColor,
  4. double playerWidth,
)

Implementation

List<AudioBar> generateAudioBars(List<double> listOfHeights,
    Color playedColor, Color unplayedColor, double playerWidth) {
  _bars = [];
  double barWidth = playerWidth / listOfHeights.length;
  barWidth = barWidth - playerWidth * 0.0075;
  for (int i = 0; i < listOfHeights.length; i++) {
    _bars.add(
      AudioBar(
        index: i,
        height: listOfHeights[i],
        playedColor: playedColor,
        unplayedColor: unplayedColor,
        width: barWidth,
        playerWidth: playerWidth,
      ),
    );
  }
  currentlyAt = audioPlayer.duration!.inSeconds ~/ _bars.length;
  return _bars;
}