Im trying to build List where you can add items on both sides which are limited (so its not infinite on both sides). On top you would do refresh, and it will load new items but you would stay on same place (and new items are on top of your current position). On bottom you gonna load more but same, stay on same place. I have tried doing this using CustomScrollView and two slivers with center, but thing that i want to do is that on refresh i want to delete some old items thing what happens is that it jumps to new center and refreshes the cards. Which is it that point on top.
Current state
CustomScrollView(
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics(),
),
center: _mainListKey,
controller: scrollController,
cacheExtent: 1000,
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return ComplexWidget(item: topItems[index]),
},
childCount: topItems.count,
),),
SliverList(
key: _mainListKey
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return ComplexWidget(item: bottomItems[index]),
},
childCount: bottomItems.count,
),),
]
),
Better description of behavior:
Well, imagine same list like here in twitter app. If you scroll down, it will load more and more, older and older, tweets. Sometimes it will load on background newer items, that are loaded to top, without making you scroll. Lastly, you can go top and pull to refresh and it will download new items(there is difference in twitter) and items are added on top of your position.
So 3 triggers:
- Scroll down to load more with indicatior
- Pull to refresh
- Automatical refresh on background
No one from those should make you change position