flutter_draggable_gridview icon indicating copy to clipboard operation
flutter_draggable_gridview copied to clipboard

Added an Index to DraggableGridItem

Open Michael2543 opened this issue 1 year ago • 0 comments

Hi,

I made a straightforward change to your package - I added an Index to DraggableGridItem. This change allows Shared Preferences to store the list of DraggableGridItems and sort them accordingly.

Please feel free to dismiss the pull request and bear with me if I did something wrong: it's my first pull request for a package. :) (I also had to add some properties to DragTargetGrid, these were mandatory by the compiler)

Thanks for your great package!

Michael

Sorting Example:

Future onDragAccept( List<DraggableGridItem> list, int beforeIndex, int afterIndex) async { List<String> indexes = []; for (var item in list) { indexes.add(item.index.toString()); } prefs.setStringList('indexes', indexes); } }


if (prefs.getStringList('indexes') != null) { List<String> indexes = prefs.getStringList('indexes')!; draggableGridItems.sort((a, b) => indexes .indexOf(a.index.toString()) .compareTo(indexes.indexOf(b.index.toString()))); }

Michael2543 avatar Feb 28 '24 12:02 Michael2543