scroll-to-index icon indicating copy to clipboard operation
scroll-to-index copied to clipboard

Support in NestedScrollView + TabbarView(ListView,GridView)

Open kimwest00 opened this issue 1 year ago • 2 comments

Hi! I'm going to develop feature that [when user click gridview item, then

  1. change gridview ->listview widget
  2. scroll to gridview item's index on Listview (e.g. instagram poster interaction)

So, I want to work with this library but I use NestedScrollView with body : TabbarView,(not CustomScrollView) and this library doesn't work

I attach code below

//in controller
AutoScrollController scrollController = AutoScrollController(
    axis: Axis.vertical,
    suggestedRowHeight: double.infinity,
  );
//in view class
NestedScrollView(
controller: controller.scrollController
headerSliver:(something),
body:TabbarView(children:
[
tab1(),
tab2(),
..
]
)
// in tab1 widget,
ListView.builder(
      controller: controller.scrollController,
      itemCount: list.length + 1,
      itemBuilder: (context, index) {
        return AutoScrollTag(
          key: ValueKey(index),
          index: index,
          controller: controller.scrollController,
          child: (child Widget something)

I register scrollController on NestedScrollView as AutoScrollController type. (At first, I register scrollController individually(on ListView,GridView, NestedScrollView), but scroll interaction either works individually, so I register scrollController only on NestedScrollview)

I also attach a picture of the widget tree to help you understand my case Thank you for read this, and want some help ASAP😭

image

kimwest00 avatar Mar 23 '24 09:03 kimwest00

Any updates on this? 🥲@jerrywell

kimwest00 avatar Jul 04 '24 06:07 kimwest00

Hi @kimwest00

It’s actually two different routes. I’m simply listing the idea here:

  1. Use the grid view without the scroll-to feature.
  2. When you tap on a cell in the grid view, it will trigger a route with a list view.
  3. The first item in this list view will be what you just tapped.
  4. Both the tapped item in the grid view and the list view will use the Hero widget.
  5. For step 3, the list view will use the center key to keep the scroll offset 0, and allowing for more newer content if any.
  6. When you want to swipe back from the list view to the grid view, you can reload the grid view and assign the first item (or whichever position) as the one you just swiped from in the list view.

So this feature actually doesn't need the scroll to feature.

jerrywell avatar Jul 09 '24 02:07 jerrywell

Close issue as we have the solution from https://github.com/quire-io/scroll-to-index/issues/112#issuecomment-2216205530

jerrywell avatar Jan 28 '25 13:01 jerrywell