[GH-ISSUE #3594] [Question] how to reorder (drag and drop) listitem ? #1632

Closed
opened 2026-03-23 20:52:02 +00:00 by mirror · 3 comments
Owner

Originally created by @kurt-steiner on GitHub (Oct 3, 2023).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/3594

hey, I am developing a todolist application, and I need to write a feature so that I can drag and drop list item, like

https://github.com/AppFlowy-IO/AppFlowy/assets/46296608/e7ed43ef-75fd-4c07-94b5-21460325d006

and I found that this project has this feature, can you tell me how to write it given such data

class Task {
  int id;
  String name;
}

class TaskGroup {
  int id;
  String name;
  List<Task> tasks;
}

image

Originally created by @kurt-steiner on GitHub (Oct 3, 2023). Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/3594 hey, I am developing a todolist application, and I need to write a feature so that I can drag and drop list item, like https://github.com/AppFlowy-IO/AppFlowy/assets/46296608/e7ed43ef-75fd-4c07-94b5-21460325d006 and I found that this project has this feature, can you tell me how to write it given such data ```dart class Task { int id; String name; } class TaskGroup { int id; String name; List<Task> tasks; } ``` ![image](https://github.com/AppFlowy-IO/AppFlowy/assets/46296608/d4948456-ecb1-4e00-abe1-bb1ed63ca95f)
Author
Owner

@emmggi commented on GitHub (Oct 3, 2023):

Package called boardview does exactly this.

The second question is about implementation? Check out the examples on the link page.

<!-- gh-comment-id:1744993469 --> @emmggi commented on GitHub (Oct 3, 2023): Package called [boardview](https://pub.dev/packages/boardview) does exactly this. The second question is about implementation? Check out the examples on the link page.
Author
Owner

@kurt-steiner commented on GitHub (Oct 3, 2023):

what? I have just only one question, is how to move the item to another group, as the video shows 😋

<!-- gh-comment-id:1745040364 --> @kurt-steiner commented on GitHub (Oct 3, 2023): what? I have just only one question, is how to move the item to another group, as the video shows :yum:
Author
Owner

@Xazin commented on GitHub (Oct 3, 2023):

You use Draggable and DragTarget.

As long as the DragTarget can accept the type of draggable from any column, you're good to go.

The widget with the DragTargets is the Column, that column should have the groupId or index of the column, to be able to get the groupTo when dragging between groups.

The Data of a Draggable, should include groupFrom and index. This will enable you make this check in the Column:

if (groupFrom == widget.groupIndex) {
  // We're just reordering within column
} else {
  // We're moving from one group to another
}

I don't know what kind of state management you prefer or use, but it should be quite simple from there.

Along with each DragTarget you should keep track of the index of that DragTarget, allowing you to move items to the correct location.


You can also, as mentioned already, use a package like boardview.

Since this is unrelated to AppFlowy itself, I'll close it with this comment.

<!-- gh-comment-id:1745254458 --> @Xazin commented on GitHub (Oct 3, 2023): You use Draggable and DragTarget. As long as the DragTarget can accept the type of draggable from any column, you're good to go. The widget with the DragTargets is the Column, that column should have the groupId or index of the column, to be able to get the `groupTo` when dragging between groups. The Data of a Draggable, should include `groupFrom` and `index`. This will enable you make this check in the Column: ``` if (groupFrom == widget.groupIndex) { // We're just reordering within column } else { // We're moving from one group to another } ``` I don't know what kind of state management you prefer or use, but it should be quite simple from there. Along with each DragTarget you should keep track of the index of that DragTarget, allowing you to move items to the correct location. --- You can also, as mentioned already, use a package like [boardview](https://www.youtube.com/watch?v=FrwEFv31onk). Since this is unrelated to AppFlowy itself, I'll close it with this comment.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#1632
No description provided.