sticky_header_list icon indicating copy to clipboard operation
sticky_header_list copied to clipboard

flutter: Another exception was thrown: RangeError (index): Invalid value: Not in range 0..1, inclusive: 2

Open thavlik opened this issue 5 years ago • 1 comments

I encounter this exception when scrolling down on a list with a header row and single regular row. It would appear that _StickyChildBuilderDelegate.build is being called with index=2, but this.children.length == 2, resulting in an array out-of-bounds exception.

Exception thrown, caught on change_notifier.dart line 208:

RangeError (RangeError (index): Invalid value: Not in range 0..1, inclusive: 2)

Call stack:

_GrowableList.[] (dart:core-patch/growable_array.dart:145)
_StickyChildBuilderDelegate.build (/Users/thomashavlik/Repositories/flutter/.pub-cache/hosted/pub.dartlang.org/sticky_header_list-1.0.6/lib/sticky_header_list.dart:239)
_StickyListState._calculateStickyOffset (/Users/thomashavlik/Repositories/flutter/.pub-cache/hosted/pub.dartlang.org/sticky_header_list-1.0.6/lib/sticky_header_list.dart:160)
_StickyListState._getScrollController.<anonymous closure> (/Users/thomashavlik/Repositories/flutter/.pub-cache/hosted/pub.dartlang.org/sticky_header_list-1.0.6/lib/sticky_header_list.dart:141)
ChangeNotifier.notifyListeners (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/foundation/change_notifier.dart:206)
ChangeNotifier.notifyListeners (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/foundation/change_notifier.dart:206)
ScrollPosition.notifyListeners (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/widgets/scroll_position.dart:701)
ScrollPosition.setPixels (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/widgets/scroll_position.dart:218)
ScrollPositionWithSingleContext.setPixels (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart:83)
ScrollPositionWithSingleContext.applyUserOffset (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart:126)
ScrollDragController.update (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/widgets/scroll_activity.dart:372)
ScrollableState._handleDragUpdate (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/widgets/scrollable.dart:498)
DragGestureRecognizer._checkUpdate.<anonymous closure> (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/gestures/monodrag.dart:383)
GestureRecognizer.invokeCallback (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/gestures/recognizer.dart:182)
DragGestureRecognizer._checkUpdate (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/gestures/monodrag.dart:383)
DragGestureRecognizer.handleEvent (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/gestures/monodrag.dart:253)
PointerRouter._dispatch (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/gestures/pointer_router.dart:75)
PointerRouter.route (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/gestures/pointer_router.dart:102)
_WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/gestures/binding.dart:218)
_WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (/Users/thomashavlik/Repositories/flutter/packages/flutter/lib/src/gestures/binding.dart:198)

Because the exception is caught and the library functions as expected in spite of the error condition, this is mainly just a nuisance as it pollutes the debug output.

Thank you for the hard work put into this widget!

thavlik avatar Aug 19 '19 15:08 thavlik

Didn't manage to reproduce it with 1 header - 1 row.

This is the smallest problem of this library. It was the first sticky library, simple implementation, but now there are much better choices (that work directly with slivers). Gonna deprecate it.

itsJoKr avatar Aug 19 '19 17:08 itsJoKr