EdsonBueno / infinite_scroll_pagination

Flutter package to help you lazily load and display pages of items as the user scrolls down your screen.
https://pub.dev/packages/infinite_scroll_pagination
MIT License
625 stars 213 forks source link

how to customize first index in grid view #293

Closed heshesh2010 closed 7 months ago

heshesh2010 commented 12 months ago

Hi , when using normal grid view I can set itemCount to +1 so I can customize first index when index ==0

`GridView.builder(
                //                     shrinkWrap: true,
                //                     itemCount: controller.worksList.length + 1,
                //                     gridDelegate:
                //                         const SliverGridDelegateWithFixedCrossAxisCount(
                //                             crossAxisCount: 3,
                //                             crossAxisSpacing: 8,
                //                             mainAxisSpacing: 8,
                //                             childAspectRatio: 1),
                //                     itemBuilder:
                //                         (BuildContext context, int index) {
                //                       if (index == 0) {
                //                         return AddNewWorksBtn(
                //                             controller: controller);
                //                       }

                //                       return WorksItemWidget(
                //                           controller: controller,
                //                           girdItemIndex: index);
                //                     }),`

but now how to achieve this in your package pls .

MarekRudzki commented 11 months ago

I have a same issue. Anyone able to get past it?

clragon commented 11 months ago

You can use a PagedSliverGrid with a CustomScrollView instead of a GridView. in the slivers parameter you can then insert your custom widget inside a SliverToBoxAdapter without it being part of the pagination.

return CustomScrollView(
  slivers: [
    SliverToBoxAdapter(
      child: FirstWidget(), // e.g. button
    ),
    PagedSliverGrid(
      // ...
    ),
  ],
);