I am wondering if following approach is okay or it will become a problem down the line. I have been using this approach where I setup an empty
companion object
in my data models and define an extension property to get a sample for that data model lazily.
data class User(val name: String, val age: Int) {
companion object
}
val User.Companion.mock by lazy { User(name = "John", age = 25) }
And I use this mock property to get sample data for my
@Preview
in Jetpack Compose. Since code defined in
@Preview
composable does not become part of live app or APK, I am wondering if it's okay to use this approach.
@Preview
@Composable
fun UserInfo() {
Text(User.mock.toString())
}