Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
thavlik opened this issue Aug 19, 2019 · 1 comment

Comments

@thavlik
Copy link

thavlik commented Aug 19, 2019

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!

@itsJoKr
Copy link
Owner

itsJoKr commented Aug 19, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants