79337352

Date: 2025-01-07 21:17:10
Score: 0.5
Natty:
Report link

In addition to @Reza's reply. In Compose, you can just pass ByteArray in model:

import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi
/*private const val*/ BASE64_SUBSTRING = "base64,"


@OptIn(ExperimentalEncodingApi::class)
val base64ImageByteArray = Base64.decode(base64ImageString.substringAfter(BASE64_SUBSTRING))

AsyncImage(
    model = base64ImageByteArray,
    contentDescription = null,
    placeholder = ColorPainter(MaterialTheme.colorScheme.surfaceContainer),
    error = ColorPainter(MaterialTheme.colorScheme.surfaceDim),
    contentScale = ContentScale.Crop,
)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Reza's
  • Low reputation (0.5):
Posted by: mxkmn