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

add a draggedItemBuilder widget to support persistent state children #164

Merged
merged 1 commit into from Oct 7, 2022

Conversation

danReynolds
Copy link
Contributor

Adds a new draggedItemBuilder feature that resolves the GlobalKey issues described in #72. To persist the state of the children passed to widgets like ReorderableColumn and ReorderableRow, I was having issues with giving the children a GlobalKey or a GlobalObjectKey since the library internally wraps the children in a KeyedSubtree with a GlobalKey based on each child's Key.

This meant that there was no way to make persistent state children, something that the referenced issue was looking to solve and that I needed for my own usage. The solution I found was to build a different widget when dragging the child using a dragged item builder, since I can then give the children a GlobalKey and make them have persistent state without conflicting with the dragged item, which can be built with a non-persistent Key.

In addition to solving the persistent children state problem I think it's also a handy feature to have in case there are any other customizations folks want to make to a draggable widget while it is actively being dragged.

I'm happy to clean up the feature and make changes as advised. Let me know what you think thanks!

@diegotori
Copy link
Collaborator

LGTM.

@diegotori
Copy link
Collaborator

@danReynolds I'm currently out of the country, but I will release a new version next week. Thanks for the PR.

@diegotori diegotori merged commit a5731ea into hanshengchiu:master Oct 7, 2022
diegotori added a commit that referenced this pull request Nov 3, 2022
@TJ-coding
Copy link

@danReynolds
@diegotori
Thanks for implementing this fix, but I think there is still a bug.

Bottom Line Up First: ReorderableTableRow initialized with GlobalKey does not render correctly when picking it up by a long press. But it still reorder correctly when placed down.

  1. When you long press a ReorderableTableRow initialized with an ObjectKey, the row hovers up.
    bug report 1
  2. This no longer happens when you initialize a ReorderableTableRow with a GlobalKey, and instead, it renders a very small shadow.
    bug report 2
    bug report 2 (copy)

When GlobalKey is used, though the rendering when you pick up a row is incorrect, when you place the row, the reordering of a row that contains a StatefulWidget happens correctly.

However, when you set ObjectKey, though the rendering works correctly, the states of the StatefulWidgets in the row are reset to initial values.

I am aware that it takes a lot of effort to manage an open source project but I would like to know f you will be looking into fixing the bug. Unfortunately, I do not have the deep enough understanding of Flutter or this package to tackle this bug.

Thanks

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

Successfully merging this pull request may close these issues.

None yet

3 participants