This package supports drag & drop widgets inside the GridView.builder for multiplatform. It provides all the properties which are available in Gridview. builder and easy to implement with the few lines of code.
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 list, int beforeIndex, int afterIndex) async {
List indexes = [];
for (var item in list) {
indexes.add(item.index.toString());
}
prefs.setStringList('indexes', indexes);
}
}
if (prefs.getStringList('indexes') != null) {
List indexes = prefs.getStringList('indexes')!;
draggableGridItems.sort((a, b) => indexes
.indexOf(a.index.toString())
.compareTo(indexes.indexOf(b.index.toString())));
}
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 list, int beforeIndex, int afterIndex) async {
List indexes = [];
for (var item in list) {
indexes.add(item.index.toString());
}
prefs.setStringList('indexes', indexes);
}
}
if (prefs.getStringList('indexes') != null) { List indexes = prefs.getStringList('indexes')!;
draggableGridItems.sort((a, b) => indexes
.indexOf(a.index.toString())
.compareTo(indexes.indexOf(b.index.toString())));
}