TLDR: The very concept of such a function makes me very nervous. It makes me think your widget is not sufficiently isolated / is not a function of its parameters. Why do you want to know if you're in a preview?
11/02/2020, 6:38 PM
@jim Maybe I would like to mock view model if you can't instantiate it in a preview
Ok, I've read you answer about this in that post
11/02/2020, 9:32 PM
For anyone who had the same question but didn't read the full thread: The general answer to "I would like to mock view model if you can't instantiate it in a preview"... your widget should be abstracted in such a way that it is not depending on a data model that is only available in your Android app, and instead should take in an interface that can be instantiated within your preview function and passed to the Composable.