Hey everyone, I have a list of images that I’m sav...
# compose
t
Hey everyone, I have a list of images that I’m saving locally, when entering the screen. I want to show them all at the same time when they are ready, in a LazyRow. To do this, I’m using produceState, to try to download the images, and return the Files of those downloaded successfully:
Copy code
val imageFiles = produceState(initialValue = emptyList<File>(), imageRefs) {
  imageRefs.map { imageRef ->
    async {
      downloadItemImage(imageRef, file)
    }
  }.awaitAll().filterNotNull()
}
Then, I’d like to map this List<File> to a List<Painter>, and send it to my ImagesRow composable, like this:
Copy code
val painters = imageFiles.value.map { file ->
  rememberImagePainter(file)
}
ImagesRow(painters = painters)
Problem is: The painters aren’t being updated when imageFiles is updated. Any ideas?
z
It looks like you’re never actually assigning
value
in your
produceState
.
👌 1
☝️ 1
t
Yep that was it! Thanks @Zach Klippenstein (he/him) [MOD]!
z
Seems like there could be a lint check. Request filed: https://issuetracker.google.com/issues/194776171