drag_select_grid_view
drag_select_grid_view copied to clipboard
How to get the select parameter outside the Gridview ?
Hi . I am using the SelectableItem
, that was created in the example code . It needs the selected parameter which needs to be passed from the itembuilder function :
itemBuilder: (BuildContext context, int index, bool selected) {
return _mediaList[index];
}),
The Problem is as you can see that i am storing the SelectableItem in a mediaList variable. So i want to find a way to get the selected parameter to get passed to the SelectableItem
.
@hugocbpassos do you have any idea about how to solve it ?
Since you want _SelectableItemState.didUpdateWidget()
to be called, the only way to do so is by creating a new widget, so you are not supposed to store a SelectableItem
.
By the way, why are you doing it?
I am using the Photo manager pacakge to retrieve media from storage .And for some other reasons i need to call SelectableItem
in another function.
Since you want
_SelectableItemState.didUpdateWidget()
to be called, the only way to do so is by creating a new widget, so you are not supposed to store aSelectableItem
.By the way, why are you doing it?
I didn't understand what you meant exactly .
I didn't understand what you meant exactly .
The whole logic of the SelectableItem
relies on _SelectableItemState.didUpdateWidget()
. The only way to get this method fired is by creating a new SelectableItem
every time selected
changes, so you can't store it.
I am using the Photo manager pacakge to retrieve media from storage .And for some other reasons i need to call SelectableItem in another function.
I'm pretty sure there are better ways to solve this. Please open a question at Stack Overflow with the details, so I (or somebody else) might be able to help you.
I created a custom class called ItemData , like : ``` class ItemData { final int index; final bool selected; ItemData({this.index, this.selected = false}); }
The i passed the index and the selected parameters to the ItemData object like that :
itemBuilder: (BuildContext context, int index, bool selected) { _itemData = ItemData(index: index, selected: selected); return _mediaList[_itemData.index]; },
The index worked fine but the selcted value doesn't work : like : `SelectableItem(
selected: _itemData.selected,
)`
Is that custom class a correct step or not . And if not is there a way to access the selected boolean through the controller ?