'Reordering an 'active' widget in flutter with Reorderables package
I'm using 'package:reorderables/reorderables.dart'
I use the ReorderableColumn which contains a column of widgets. The 'normal' drag/drop works fine when the contents of the widgets are not changing.
The issue is that if the widgets being dragged is 'active', as in there is some activity going on that is causing rebuilds (a file is being uploaded, and there is a progress indicator, status updates etc), the system crashes with messages like:
Error: setState() called after dispose(): _FilePickerWidgetState#174b4(lifecycle state: defunct, not mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
From what I understand this package removes and inserts the widget from the widget tree for a more realistic visual simulation.
Could you suggest a solution or alternative?
Solution 1:[1]
I was able to replace this with the Flutter build-in ReorderableListView - there are less controls available, but I no longer get any errors.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sunil Gupta |