Giter Site home page Giter Site logo

Comments (15)

Kavantix avatar Kavantix commented on August 15, 2024

Can you elaborate on what you would expect a MultiSliver.builder to be?

from sliver_tools.

LucasAschenbach avatar LucasAschenbach commented on August 15, 2024

I think he is suggesting to add an option to also provide a sliver builder function instead of the children argument. This is sometimes preferred, or even necessary, as the number of children grows since instantiating all children on the first build can be very expensive or even impossible in case of an infinite list. With a builder each child is only instantiated once it needs to be painted. (Similar to SliverChildListDelegate vs. SliverChildBuilderDelegate)

from sliver_tools.

Kavantix avatar Kavantix commented on August 15, 2024

@LucasAschenbach thanks for attempting to clarify, however that part I understood. I should have been a bit clearer in my question.

The question I meant was: How would you expect a MultiSliver.builder to work. Because slivers are always built since their position in the list doesn’t necessarily mean that they will be drawn after the item before it. For instance, sticky headers work because they always get the chance to layout even if they are way earlier in the list.
I do have a ticket open #10 which proposes an idea to manually optimize expensive slivers.

from sliver_tools.

cgestes avatar cgestes commented on August 15, 2024

We can close 😁
I did differently. I don't know enough about the subject to understand the issue even less to propose a solution.

from sliver_tools.

cgestes avatar cgestes commented on August 15, 2024

from sliver_tools.

Kavantix avatar Kavantix commented on August 15, 2024

@cgestes perhaps I can help come up with a solution for your specific problem, I still feel a builder version of MultiSliver is not possible with the current flutter implementation of Slivers

from sliver_tools.

cgestes avatar cgestes commented on August 15, 2024

I believe it is ok to leave it closed :)

I have not enough context any more to provide any useful information.

I dont even remember how I sorted out my issue in the end.

Thank you @Kavantix .

from sliver_tools.

cbarlow26 avatar cbarlow26 commented on August 15, 2024

Not sure if I should comment here or create a new issue to continue the discussion.

You might be right about Flutter's implementation of slivers and that it's not possible to create MultiSliver with a builder delegate, but then, how does SliverList accomplish this? The problem with SliverList is that it expects the builder to return render boxes and we need to return render slivers.

What are your thoughts?

from sliver_tools.

Kavantix avatar Kavantix commented on August 15, 2024

@cbarlow26 the problem you point out is exactly the difference that makes it not possible to do it the way SliverList does it. What SliverList basically does is only build a small subset of the children, but for slivers you always need to build all of them so there would be no time saved

from sliver_tools.

cbarlow26 avatar cbarlow26 commented on August 15, 2024

@Kavantix Thank you for the explanation. That's very interesting.

In my case, and maybe others as well, I'm trying mix render boxes and render slivers inside a single SliverList. It's much easier to leverage SliverList's builder delegate than to roll my own widget that listens to scrolling events and then manually constructs a list of [SliverPinnedHeader, SliverList, SliverPinnedHeader, SliverList, etc...].

Specifically, I'm using PagedSliverList from the infinite_scroll_pagination package and I want my items to have pinned headers. Internally, PagedSliverList uses a single SliverList that is updated when new items are fetched.

Any insights or solutions that you may have would be greatly appreciated. Thanks!

from sliver_tools.

Kavantix avatar Kavantix commented on August 15, 2024

How many of these pairs of sliver list and pinned header do you have?

from sliver_tools.

cbarlow26 avatar cbarlow26 commented on August 15, 2024

@Kavantix The list is fetched from a database and is infinite. Each call to the database retrieves a "page" worth of items which, in my case, is anywhere from 3 to 10 items. The SliverList only contains 3 to 5 pages at one time; the one currently visible and some buffered pages at the beginning and end. So, there would be 3 to 5 pairs of pinned headers and sliver lists at any one time, depending on how I configure page buffering.

The items are built as soon as they're retrieved from the database, so for me, I think it's ok if all the silvers are built. I think SliverList might do something similar. It seems to call the build delegate until the viewport is full. Just guessing.

Anyway, thanks!

from sliver_tools.

cbarlow26 avatar cbarlow26 commented on August 15, 2024

I may have misspoke. PagedSliverList may keep the entire list of items and rebuild the SliverList when new items are added and just buffer the end of the list.

from sliver_tools.

Kavantix avatar Kavantix commented on August 15, 2024

You are correct about sliverlist building only what it needs, Listview is just a sliverlist but with a scrollview already configured around it.

But if you are ok with building all the widgets, what is the builder version than useful for?
you could simply build the pairs of slivers in a for look right?

from sliver_tools.

cbarlow26 avatar cbarlow26 commented on August 15, 2024

The advantage of the SliverList builder version is that it automatically asks the builder for more items when the view scrolls to the end of the list. This is when I can fetch more items from the db. The non-builder version has no scrolling callbacks, so I'd have to create a custom widget that mimics this behavior. Maybe it's not as hard as I think, but I'd rather not reinvent the wheel.

I was hoping to simply replace my use of SliverList with MultiSliver, but I see your point about having to build all the slivers up front. That's unexpected behavior when using a builder method. My use case might be unique.

Thanks for helping me think through this. I'll post back if I come up with something clever.

from sliver_tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.