Skip to content

Instantly share code, notes, and snippets.

@skydoves
Created January 4, 2026 08:57
Show Gist options
  • Select an option

  • Save skydoves/a95be9d8c50bb6455097d3b8c0b37c3c to your computer and use it in GitHub Desktop.

Select an option

Save skydoves/a95be9d8c50bb6455097d3b8c0b37c3c to your computer and use it in GitHub Desktop.
Landscapist: Loading Images with Flow
import com.skydoves.landscapist.core.ImageRequest
import com.skydoves.landscapist.core.model.ImageResult
suspend fun loadImage(url: String) {
val request = ImageRequest.builder()
.model(url)
.size(width = 800, height = 600)
.build()
landscapist.load(request).collect { result ->
when (result) {
is ImageResult.Loading -> {
println("Loading...")
}
is ImageResult.Success -> {
val imageBitmap = result.data
val dataSource = result.dataSource // MEMORY, DISK, or NETWORK
println("Loaded from: $dataSource")
}
is ImageResult.Failure -> {
val error = result.reason
println("Error: ${error.message}")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment