fluttercommunity / flutter-draggable-scrollbar

Draggable Scrollbar - A scrollbar that can be dragged for quickly navigation through a vertical list. Additional option is showing label next to scrollthumb with information about current item. Maintainer: @marica27
https://pub.dev/packages/draggable_scrollbar
MIT License
441 stars 77 forks source link

Perfect #1

Closed ghost closed 6 years ago

ghost commented 6 years ago

This is awesome.

I have a request. You know how in a contracts app where you have a draggable scrollbar and it shows the first letter of the area you up to. For example as I drag scroll from N to O in the list it shows an O near the scroll bar ( or maybe in the top right of the screen ).

Not sure how to do it because it means the scroll batmr needs to be sent a signal from the list view as it goes from N to O. So it's coupled.

marica27 commented 6 years ago

Thanks, @gedw99.

Yes, scrollbar and list view are coupled in some way. You need to provide labelTextBuilder. You can do it like this. You need to know heights of rows in your list view.

labelTextBuilder: (offset) {
        final int currentItem = offset ~/ _heightOfRowInListView;
        var letter =  _data[currentItem].name.substring(0,1);
        return Text("$letter");
      }
ghost commented 6 years ago

thanks @marica27 for the example code. It works well :) Will close this...