calculateOpacity method

double calculateOpacity(
  1. int index
)

Calculate opacity transformation for dynamic item opacity

Implementation

double calculateOpacity(int index) {
  //scroll-pixel position for index to be at the center of ScrollSnapList
  double intendedPixel = index * widget.itemSize;
  double difference = intendedPixel - currentPixel;

  return (difference == 0) ? 1.0 : widget.dynamicItemOpacity ?? 1.0;
}