thechinkysight / paginable

A Flutter package which makes pagination easier.
https://pub.dev/packages/paginable
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

Confilct with carousel_slider #24

Open Donk3ys opened 2 years ago

Donk3ys commented 2 years ago

Describe the bug When sliding through a carousel from the carousel_slider package the loadMore function gets called from paginable.

Not sure how the two are conflicting or if there is a work around.

To Reproduce

class TestError extends StatelessWidget {
  final List<List<Color>> itemList = [
    [Colors.black87, Colors.black54],
    [Colors.white38, Colors.white54],
    [Colors.red, Colors.redAccent],
    [Colors.blue, Colors.blueAccent],
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PaginableCustomScrollView(
        loadMore: () async => print("CALLED LOAD MORE"),  //  THIS SHOULD NOT GET CALLED WHEN SCROLLING CAROUSEL
        slivers: [
          SliverList(
            delegate: PaginableSliverChildBuilderDelegate(
              (context, index) {
                final item = itemList.elementAt(index);
                return CarouselSlider(
                  options: CarouselOptions(
                    height: MediaQuery.of(context).size.height * 0.5,
                    enableInfiniteScroll: false,
                  ),
                  items: item
                      .map(
                        (clr) => Container(
                          color: clr,
                          child: const Center(child: Text("< Swipe >")),
                        ),
                      )
                      .toList(),
                );
              },
              childCount: itemList.length,
              errorIndicatorWidget: (exception, tryAgain) =>
                  PaginationErrorWifdget(
                exception: exception,
                tryAgain: tryAgain,
              ),
              progressIndicatorWidget: const PaginationLoadingWidget(),
            ).build(),
          ),
        ],
      ),
    );
  }
}

Run code above and read console output

Additional context Not sure if this even affects your package but just though id let you know in case you have an easy workaround.

Donk3ys commented 2 years ago

I did a bit of testing and it seams the carousel package triggers the ScrollUpdateNotification.

if I add a check for scrollUpdateNotification.dragDetails?.delta != null before performPagination() the error seems to be fixed... its a bit of a hacky solution unfortunately but does the job for now.