Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing the ability to insert Sliver children #122

Open
creativecreatorormaybenot opened this issue Jul 20, 2021 · 6 comments
Open

Missing the ability to insert Sliver children #122

creativecreatorormaybenot opened this issue Jul 20, 2021 · 6 comments
Labels
feature New feature or request

Comments

@creativecreatorormaybenot

Feature request

This request is similar to #48, however, the use case is actually not yet covered by the package (not that I know). Namely, we need section headers, which requires to have slivers as children of the paged list.

Current support

What you can do currently is implement a sticky header:

slivers: [
  StickySliverHeader(...),
  PagedSliverList(...),
],

However, you cannot have section headers, i.e.:

PagedSliverList(
  pagingController: viewModel.pagingController,
  builderDelegate: PagedChildBuilderDelegate<LearningPlansOverviewItem>(
    itemBuilder: (context, item, index) {
      if (item is SectionHeaderItem) {
        return SliverHeader(...);
      }
      return RegularItemTile(...);
  ),
),

Proposal

It would be nice to have a version of the PagedSliverList that allows to have a PagedSliverBuilderDelegate that allows you to return Slivers instead of regular widgets (render box contract).

@EdsonBueno if you have another idea how to solve this, let me know.

@EdsonBueno
Copy link
Owner

EdsonBueno commented Oct 17, 2021

Hi @creativecreatorormaybenot ,
I'm curious to know how you'd do that with a regular SliverList, because it seems to me that not even SliverList works this way.

@creativecreatorormaybenot
Copy link
Author

@EdsonBueno Why do you think that this is not possible?

The way you do it is by placing the sticky headers as slivers into the CustomScrollView (see this for example). You do not place inside of the SliverList, but that is also not how it is supposed to work.

The reason this is not possible with PagedSliverList is that the headers need to be added as part of the paging. That is, to support this, PagedSliverList would need to work with the sliver contract in a way where it places the header slivers in between sections of render box children.

@EdsonBueno
Copy link
Owner

By doing this, we would loose the ability to build children on demand, since CustomScrollView takes all its children at once, and not via a builder.
This library relies on having the children built on demand to know when it's time to fetch more items.

@creativecreatorormaybenot
Copy link
Author

@EdsonBueno You can implement the same logic using a builder.

That is also what I am saying btw - this is possible without pagination / a builder, but with the pagination package it is not possible at the moment. It would of course need to be implemented.

@ariefwijaya
Copy link

ariefwijaya commented Dec 17, 2022

We need this feature.

For now, we can use this plugin to use sticky headers inside listview https://pub.dev/packages/sticky_headers

@therohansanap
Copy link

Adding some more example to this request. I stumbled upon exactly this same problem recently. My use case is as follows:

  • Full page needs to be vertically scrollable.
  • Page starts with title, followed by on horizontal list, followed by a paged grid which is grouped in sections with section title as header.

I stumbled upon this example for sticky header which uses sliver_tools for sticky header. They use simple trick of returning a MultiSliver in a sliver based list.

The way PagedSliverList is implemented in this package, it only accepts PagedChildBuilderDelegate which has an item builder from which we are not allowed to return sliver based widget. It is mandatory to return a RenderBox based widget. It breaks if we return a RenderSliver based widget from PagedChildBuilderDelegate's item builder.

@clragon clragon added the feature New feature or request label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants