Here is the situation:
I am allowing user to pick items from a listview and add them as favorite.
When the list loads for first time I preselect the items that were added previously as favorites.
To save favorites I can simply get the selection list and overwrite the favorites, that is if anything deselected will be taken care automatically.
BUT:
On top of the listview there is a search box which refreshes the same listview to show search results for every new search keyword. So user can search and select/deselect items. This situation does not allow me to simply take the selection list and overwrite the favorites.
I need to explicitly know which item user tapped on (note my listview’s tapBehavior is set to toggleSelect) to select/deselect it and manually add/remove it from favorite list.
How can I get the information about the item that triggered the onselectionchanged event of the listview and also the current state of that item (i.e. selected/deselected).
You could add handler for selectionchanging event and compare event.detail.newSelection with current selection of listview control. Missing/new items will be required elements.
I’m not sure that this solution is most optimal but at least it works.