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
612 stars 202 forks source link

[Question] Any way to center the CircularProgressIndicator in a PagedSliverGrid? #236

Closed pongloongyeat closed 1 year ago

pongloongyeat commented 1 year ago

I have a PageSliverGrid with a crossAxisCount of 2. On loading, the grid shows the loading indicator as if it were an additional GridView child (showNewPageProgressIndicatorAsGridChild). Is there any way to change this behaviour to show it separately and in the middle?

What the grid looks like now

| x | x |
| x | x |
| o |         <- Loading indicator

What I'm trying to achieve

| x | x |
| x | x |
    o

Looking at it roughly, it seems that I could make a custom PagedSliverBuilder and modify this https://github.com/EdsonBueno/infinite_scroll_pagination/blob/a9beb8d5c2b065d2526e768e7d405be7a5f2eb30/lib/src/ui/paged_sliver_grid.dart#L159-L167

to

return SliverList(
  delegate: SliverChildListDelegate(
    [
       SliverGrid(
         gridDelegate: gridDelegate,
         delegate: _buildSliverDelegate(),
      ),
      appendixBuilder!(context),
    ],
  ),
);

but it doesn't seem to be possible to place a SliverGrid into a SliverList. Am I missing something? Or is this behaviour already configurable by default for this package but I'm just blind?

pongloongyeat commented 1 year ago

I am absolutely stupid. I wrote it out myself. This can be resolved by setting showNewPageProgressIndicatorAsGridChild to false.