hey guys, can you help me with this simple questio...
# compose
v
hey guys, can you help me with this simple question: How can I check for “preview” state inside composable? Can I know when the view is rendering in preview environment?
k
Why would you want to know that? What do you want to do in preview that you wouldn't want to do in the "real" on-device flow?
v
I’m using accompanist lib (for network-image) and it crashes in preview mode, ’cause picasso isn’t available.
thinking about wrap this inside a composable and draw the correct image in production and a placeholder simple image in preview mode.
j

https://youtu.be/exjL2kGPngI?t=185

A solution could be a
sealed class
which accept a normal local drawable and a url, so you can use the normal drawable branch as fake for previews for example
v
thanks @Javier
@Javier is a good idea to use an ambient provider?
c
Using accompanist for image loading crashes in @Preview? Sounds like accompanist should/could handle that, no?
v
@Colton Idle yeps!