Skip to content

Commit

Permalink
RangeError (RangeError (index): Invalid value) (#55)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Dimitrios Begnis <[email protected]>
  • Loading branch information
SC8885 and Dimibe authored Sep 29, 2023
1 parent 0819d26 commit 36f6c68
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/src/sticky_grouped_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,14 @@ class StickyGroupedListViewState<T, E>

int index = currentItem.index ~/ 2;
if (_topElementIndex != index) {
E curr = widget.groupBy(sortedElements[index]);
E prev = widget.groupBy(sortedElements[_topElementIndex]);
if (prev != curr) {
if (_topElementIndex < sortedElements.length) {
E curr = widget.groupBy(sortedElements[index]);
E prev = widget.groupBy(sortedElements[_topElementIndex]);
if (prev != curr) {
_topElementIndex = index;
_streamController.add(_topElementIndex);
}
} else {
_topElementIndex = index;
_streamController.add(_topElementIndex);
}
Expand Down Expand Up @@ -357,7 +362,7 @@ class StickyGroupedListViewState<T, E>
}

Widget _showFixedGroupHeader(int index) {
if (widget.elements.isNotEmpty) {
if (widget.elements.isNotEmpty && index < sortedElements.length) {
_groupHeaderKey = GlobalKey();
return Container(
key: _groupHeaderKey,
Expand Down

0 comments on commit 36f6c68

Please sign in to comment.