From 7909991612b29d4799bc3e4510514380d7ef1037 Mon Sep 17 00:00:00 2001 From: Sailesh Dahal Date: Thu, 28 Sep 2023 10:58:33 +0545 Subject: [PATCH] feat: add key to `DragAndDropItem` and `DragAndDropList` --- lib/drag_and_drop_item.dart | 3 ++- lib/drag_and_drop_list.dart | 5 ++++- lib/drag_and_drop_list_interface.dart | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/drag_and_drop_item.dart b/lib/drag_and_drop_item.dart index 2f0dccf..e96f45e 100644 --- a/lib/drag_and_drop_item.dart +++ b/lib/drag_and_drop_item.dart @@ -12,10 +12,11 @@ class DragAndDropItem implements DragAndDropInterface { /// Set to true if it can be reordered. /// Set to false if it must remain fixed. final bool canDrag; - + final Key? key; DragAndDropItem({ required this.child, this.feedbackWidget, this.canDrag = true, + this.key, }); } diff --git a/lib/drag_and_drop_list.dart b/lib/drag_and_drop_list.dart index d071581..e2c347e 100644 --- a/lib/drag_and_drop_list.dart +++ b/lib/drag_and_drop_list.dart @@ -47,9 +47,10 @@ class DragAndDropList implements DragAndDropListInterface { /// Set to true if it can be reordered. /// Set to false if it must remain fixed. final bool canDrag; - + final Key? key; DragAndDropList({ required this.children, + this.key, this.header, this.footer, this.leftSide, @@ -95,6 +96,7 @@ class DragAndDropList implements DragAndDropListInterface { } return Container( + key: key, width: params.axis == Axis.vertical ? double.infinity : params.listWidth - params.listPadding!.horizontal, @@ -122,6 +124,7 @@ class DragAndDropList implements DragAndDropListInterface { } for (int i = 0; i < children.length; i++) { allChildren.add(DragAndDropItemWrapper( + key: children[i].key, child: children[i], parameters: parameters, )); diff --git a/lib/drag_and_drop_list_interface.dart b/lib/drag_and_drop_list_interface.dart index 839528c..a7e8520 100644 --- a/lib/drag_and_drop_list_interface.dart +++ b/lib/drag_and_drop_list_interface.dart @@ -10,7 +10,6 @@ abstract class DragAndDropListInterface implements DragAndDropInterface { /// Set to true if it can be reordered. /// Set to false if it must remain fixed. bool get canDrag; - Widget generateWidget(DragAndDropBuilderParameters params); }