Код: Выделить всё
// Coil
implementation "io.coil-kt:coil-compose:1.4.0"
Previously I used the coil together with Google's
Код: Выделить всё
accompanist
Код: Выделить всё
target
Код: Выделить всё
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.pokedex, PID: 13502
java.lang.IllegalArgumentException: request.target must be null.
at coil.compose.ImagePainterKt.rememberImagePainter(ImagePainter.kt:94)
...
When browsing the internal code of
Код: Выделить всё
ImagePainter
Код: Выделить всё
target
Код: Выделить всё
@Composable
fun rememberImagePainter(
request: ImageRequest,
imageLoader: ImageLoader,
onExecute: ExecuteCallback = ExecuteCallback.Default,
): ImagePainter {
requireSupportedData(request.data)
require(request.target == null) { "request.target must be null." }
...
Here's my component in jetpack compose (the image component is inside a column):
Код: Выделить всё
Image(
modifier = Modifier
.size(120.dp)
.align(Alignment.CenterHorizontally),
painter = rememberImagePainter(
data = entry.imageUrl,
builder = {
crossfade(true)
target {
viewModel.calcDominantColor(it) { color ->
dominantColor = color
}
}
transformations(CircleCropTransformation())
},
),
contentDescription = entry.pokemonName
)
Код: Выделить всё
viewModel
Код: Выделить всё
drawable
Источник: https://stackoverflow.com/questions/698 ... tpack-comp