Closed hyperpanthera closed 5 years ago
Is this reproducible with the provided example?
Also, please wrap the stacktrace with ``` to format it properly
@knopp I will try the provided example tomorrow and report back. Late here at the moment.
I used only ListTile's so far. Thanks for the answer.
Also, do your ReorderableItem
s have stable keys?
@knopp Yes, I am displaying categories as ListTiles. As key, I am using the unique ids of the categories. No duplicates at all.
I will try it on the example tomorrow and report back. I'm curious now if I can replicate it.
Everything works in my app if I make a pause like 1 - 2 seconds before using the handle again.
@knopp It works smoothly in the example provided by your library.
I will try to figure out the problem in my code to report back on here for people that may end up with the same issue.
If you can provide a minimal reproducible example I can look into that.
@knopp
If I remove rebuildStates();
the error vanishes.
rebuildStates()
just does setState() for the parent widget. Also if I remove it, the names mess up after I move a ListTile, then redrag the previously moved ListTile.
It's this library: https://pub.dev/packages/states_rebuilder
Well, the reorder function ReorderableList takes provides two keys, not indices. So it looks like maybe you're using another layer there, in which case I'm not sure I can help you here.
I'm also not sure what rebuildStates does and why it is even necessary. Does your UI inside the list change on reodrer (other than reordering items)?
As far as I can tell from the initial error report, it looks like the key/indices get out of sync at some point. I made a deliberate decision in the tree to always work with keys instead of indices in tree api, because keys are supposed to be stable for reach item where as indices change during reodering.
@knopp Yes, I am using this as extra layer: https://gist.githubusercontent.com/ffeu/127c2b76d891fa12c9e2c831def785c4/raw/ceb07bab84f4e1fac685290cb3e50973a56cd20e/reorderable_list_simple.dart
However, the extra layer works in its provided demo. I will need to figure out what the problem in my case is.
@knopp The issue was resolved after I removed async from onReorder(), seems like doing await in onReorder() is not a good idea!
If you use the handle to change the order of an item, drop the handle then quickly try to move another handle, you get an error like update() called on null at line: (package:flutter_reorderable_list/flutter_reorderable_list.dart:243:17)
After that you can't move any of the handles anymore. It gets broken. Try around a few times then you will see. I use ListTiles.