ariedov / flutter_snaplist

A small library for creating snapping lists.
MIT License
452 stars 53 forks source link

The data.center is showing wrong values #15

Open lambasoft opened 5 years ago

lambasoft commented 5 years ago

In my code, the data.center is not showing the correct indexes, sometimes it's even showing the same center index for different pages.


SnapList(
    padding: EdgeInsets.only(
        left: (screenSize.width - cardSize.width) / 2),
    sizeProvider: (index, data) => cardSize,
    separatorProvider: (index, data) => Size(10.0, 10.0),
    positionUpdate: (int index) {
        print("Current Index: ${index}/${pageCards.length}");
        if (index == pageCards.length - 1) {
            //                          loadMore();
        }
    },
    builder: (context, index, data) {
        print("###########################");
        print("Index: ${index}");
        print("Center: ${data.center}");
        print("Next: ${data.next}");
        print("Progress: ${data.progress}");
        return ProfileCard(pageCards[index], image1, offset,
            () {}, dismissCard);
    },
    count: pageCards.length,
)
lambasoft commented 5 years ago

I think its because the builder is not being updated with the latest center index when the scroll event is finished. Im working on a fix

lambasoft commented 5 years ago

I might be the problem, but the data provided to the builder is all wrong values. Can someone confirm?

phattranky commented 5 years ago

@lambasoft I got same your problem that I mentioned at https://github.com/ariedov/flutter_snaplist/issues/11