Add the dependency below to your module's build.gradle
file:
dependencies {
implementation "com.github.skydoves:landscapist-coil3:$version"
}
dependencies {
implementation("com.github.skydoves:landscapist-coil3:$version")
}
If you're targeting on Kotlin Multiplatform, add the dependency below to your module's build.gradle.kts
file:
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.github.skydoves:landscapist-coil3:$version")
}
}
}
The coil3-landscapist
package functions identically to the coil-landscapist
package, with the key distinction being its focus on Kotlin Multiplatform. This enables the use of Coil3 across various platforms, including Android, iOS, and Desktop (JVM), facilitating a unified image loading experience across different environments.
Note
Please make sure your project uses the same Jetpack Compose version on the release page.
CoilImage¶
You can load images by using the CoilImage
composable function as the following example below:
CoilImage(
imageModel = { imageUrl }, // loading a network image or local resource using an URL.
imageOptions = ImageOptions(
contentScale = ContentScale.Crop,
alignment = Alignment.Center
)
)
Compose Metrics¶
According to the Compose Compoler Metrics, the CoilImage
Composable function is marked as Restartable and Skippable. This means you don't have to worry about performance issues related to re-rendering or re-fetching problems that can occur during recomposition. The Composable function's restartable and skippable nature ensures that the necessary actions are taken to optimize rendering, making it more efficient and seamless.