scroll-to-index
scroll-to-index copied to clipboard
Unhandled Exception: Cannot get renderObject of inactive element.
- Firstly, the lastest version of this packages can not run below Flutter 3.0.
- And, it can't jump to the listview item, which showed previoulsy then be inactive in a long listview.builder. The exception meessage is under below.
Can you help make it still available on Flutter 2.x and give me some suggestion on question 2.
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: Cannot get renderObject of inactive element.
In order for an element to have a valid renderObject, it must be active, which means it is part of the tree.
Instead, this element is in the _ElementLifecycle.inactive state.
If you called this method from a State object, consider guarding it with State.mounted.
The findRenderObject() method was called for the following element:
AutoScrollTag-[<1480198977>]
#0 Element.findRenderObject.
You can set cacheExtent
of ListView.Builder
to big number to fix problem number 2.
e.g.:
ListView.builder(
cacheExtent: 10000,
...
),