Quantcast
Channel: Active questions tagged listview - Stack Overflow
Viewing all articles
Browse latest Browse all 684

Update composable when list changes

$
0
0

I've got a composable on a Screen which shows a list of Track items (favourites):

var favourites: MutableList<Track> by mutableStateOf(mutableListOf())
@ExperimentalFoundationApi@Composableprivate fun ResultList(model: FreezerModel) {    with(model) {        if (favourites.isEmpty()) NoDataMessage("No favourites yet")        else {            LazyColumn(state = rememberLazyListState()) {                items(favourites) {                    TrackCard(it, model)                }            }        }    }}

On click events, I am updating my favourites list (add/remove item). How can I make my composable reflect these changes immediately (like to re-draw itself or something similar)? So far, it only works when I first switch to another screen.


Viewing all articles
Browse latest Browse all 684

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>