0

The idea is to basically create Listview that starts from different position flutter.

I would like to create a list view of widgets that doesn't start from the beginning. So what I mean is imagine I want the widget to start at the index 3. The 3rd widget would be the top most widget but I would be able to scroll up and down.

This is a similar logic to instagram, if you click on an image on someones page, you get sent to a big picture page that depending on the position of the picture in the list of posts, you should be able scroll up or down the big picture list view.

I hope this explains the idea I am talking about. I have two list views and I want to persist the index of the the widget I am passing between screens.

Thanks for the help.

1 Answers1

0

Thanks to the links up top, I used the ScrollablePositionedList class.

ItemScrollController _scrollController = ItemScrollController();

ScrollablePositionedList.builder(
  itemScrollController: _scrollController,
  initialScrollIndex: startIndex,
  itemCount: _myList.length,
  itemBuilder: (context, index) {
    return _myList[index];
  },
)

The key is that we have to pass the index that was clicked and make sure we set it as the initialScrollIndex.

https://pub.dev/packages/flutter_widgets https://pub.dev/documentation/flutter_widgets/latest/flutter_widgets/ScrollablePositionedList-class.html