hcbpassos / drag_select_grid_view

A grid that supports both dragging and tapping to select its items.
BSD 2-Clause "Simplified" License
133 stars 34 forks source link

how to Get Selected Values instead of indexes #16

Closed rockstarvibu closed 4 years ago

rockstarvibu commented 4 years ago

Hey I'm able to get Selected index by calling controller.value. but instead of indexes I want the values which the user selected.. how to do that... Thanks

rockstarvibu commented 4 years ago

reply

hcbpassos commented 4 years ago

DragSelectGridView cannot provide you such information because it doesn't link any data to any index. In fact, the indexes are used by the library users to decide which widget to build in DragSelectGridView.itemBuilder, not by the library itself.

As this issue doesn't concern the library, I'm closing it. However, I believe I should be able to help you with your problem if you give me more details about what are you trying to do. Some code would also help :)

rockstarvibu commented 4 years ago

Hey i just want to get the selected values in array... For eg... User selected 5 items out of 100 items and when he clicks on FAB button then on next screen 5 selected values should come instead of 5 index in array. Can u help me with this?

Thanks

rockstarvibu commented 4 years ago

?

hcbpassos commented 4 years ago

I'm guessing you have access to the list with your values, so you could do something like:

final selectedValues = controller.value.selectedIndexes.map((index) => myValues[index]);

If this doesn't help you, I'll need some minimal piece of reproducible code to get a better understanding of your situation.