fluttercommunity / fluttercommunity/flutter-draggable-scrollbar
Index out of bounds when scrolling to the very end
- Dominant language
- Dart
- Stars
- 442
- Forks
- 72
- PR merge metrics
- No merged PRs in 30d
Description
draggable_scrollbar 0.0.4
Flutter version 1.0.0
Framework revision 5391447fae (3 weeks ago), 2018-11-29 19:41:26 -0800
Engine revision 7375a0f414
Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
When I use the code suggested in the example:
```
labelTextBuilder: (offset) {
final int currentItem = controller.hasClients
? (controller.offset /
controller.position.maxScrollExtent *
numItems)
.floor()
: 0;
return Text("$currentItem");
}
```
and scroll all the way to the end of the list, the index gets out of bounds. I was able to solve this problem by adding 1 pixel to the _controller.position.maxScrollExtent:
```
labelTextBuilder: (offset) {
final int currentItem = controller.hasClients
? (controller.offset /
(controller.position.maxScrollExtent + 1) *
numItems)
.floor()
: 0;
return Text("$currentItem");
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.