The current implementation is primitive and needs a proper rewrite. While TreeSlivers could be considered, this package was specifically created to avoid the rendering issues they introduced, so a custom approach aligned with the existing TreeNode model is preferred.
To support a flat-list rendering model, the following steps are needed:
- Introduce a new list in the
TreeController that contains nodes in depth-first order.
- For each node, track: its depth (already done), its index in the flat list, and the index of its last descendant.
- Render the tree using this flat list, using depth to determine indentation.
- Implement expand/collapse by compressing or expanding the items in range from
nodeIndex + 1 to lastDescendantIndex.
The current implementation is primitive and needs a proper rewrite. While TreeSlivers could be considered, this package was specifically created to avoid the rendering issues they introduced, so a custom approach aligned with the existing
TreeNodemodel is preferred.To support a flat-list rendering model, the following steps are needed:
TreeControllerthat contains nodes in depth-first order.nodeIndex + 1tolastDescendantIndex.