Skip to content

Fix dynamicItemOpacity not work on last item when anchor MIDDLE #25

@MarnoDev

Description

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

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

Add .toInt() to final int difference = (intendedPixel - currentPixel).toInt();

Use int is better here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions