Comments (15)
Can you elaborate on what you would expect a MultiSliver.builder to be?
from sliver_tools.
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.
@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.
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.
from sliver_tools.
@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.
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.
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.
@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.
@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.
How many of these pairs of sliver list and pinned header do you have?
from sliver_tools.
@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.
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.
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.
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)
- SliverPinnedHeader and detecting overlapping (i.e. overlapsContent) HOT 1
- Is there any way I can listen when the header sticks to the top?
- Add SliverClip.clipBehavior HOT 1
- SliverPinnedHeader add offsetTop can not work correctly HOT 3
- issues with dynamic list data HOT 2
- AbstractNode is deprecated
- Error: A constant constructor can't call a non-constant super constructor. HOT 2
- Workaround for adding Sliver into an IndexedStack HOT 1
- Flutter 3.13 Compatibility HOT 2
- `SliverList` breaks alignment in `SliverStack` HOT 2
- Flutter build fails with error after new update! HOT 4
- Question: Trying to combine a SliverPinnedHeader with an SliverAppBar that has a bottom widget HOT 4
- Missing tag on GitHub HOT 2
- [Enhancement Request] SliverAnimationSwitcher with transitionBuilder HOT 1
- sliver_tools vs normal slivers HOT 1
- Please provide the full example code from the gif HOT 3
- Multiple SliverPinnedHeader overlapping HOT 2
- How to make it fit with custom ExpansionTile Widget ? HOT 1
- Add SliverSizeTransition HOT 6
- MultiSliver fails in a shrinkwrapped, unconstrained CustomScrollView HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sliver_tools.