tp7309 / flutter_sticky_and_expandable_list

粘性头部与分组列表Sliver实现 Build a grouped list, which support expand/collapse section and sticky headers, support use it with sliver widget.
MIT License
140 stars 29 forks source link

Jump scroll to header section #8

Closed guitar09 closed 4 years ago

guitar09 commented 4 years ago

Is it possible to scroll the list to a specific index in the header(pinned)?

for example: scrollControler.jumpTo(sectionIndex);

sorry my bad english

tp7309 commented 4 years ago

Sorry, the current version does not support jump to specified items. There are the following temporary solutions:

  var _controller = ExpandableListController();
  var _listController = ScrollController();

        onTap: () {
          bool hasSeparator = false;
          int indexInListView = hasSeparator ? sectionIndex * 2 : sectionIndex;
          //get section offset, can not get the offset which not visible on screen.
          double offset = _controller.containerOffsets[indexInListView];
          _listController.animateTo(offset,
              duration: Duration(microseconds: 1000), curve: Curves.linear);
        });
daviresio commented 4 years ago

p where i can associate this value to ExpandableListView? var _controller = ExpandableListController();

because if i define this variable and print _controller.containerOffsets;

i received a empty array

tp7309 commented 4 years ago

see example.

tp7309 commented 3 years ago

I have added an example of scroll to index.