https://kotlinlang.org logo
#compose
Title
# compose
t

Tung97 Hl

06/13/2023, 5:26 AM
Are there third-party libs or solutions to capture a composable widget (compose multiplatform - not jetpack compose)? For Jetpack Compose I know the excellent lib named ScreenShotBox (smarttoolfactory). But I don't know how to do it in compose multiplatform by Jetbrain.
s

Sergey Y.

06/13/2023, 9:23 AM
If you meant, render it to bitmap, then JetBrains Compose has built-in tools for that. Check ImageComposeScene. Surprisingly, I didn't find any documentation on it, here are tests to check how to use it https://github.com/JetBrains/compose-multiplatform-core/blob/47f4c4bb46808454de8e83fcaa0f2e86bf1e1d2d/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/ImageComposeSceneTest.kt#L52
...although it seems that it will only work for the compose desktop. 🤔