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

Added an Index to DraggableGridItem #25

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Michael2543
Copy link

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())));
}

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.

1 participant