I am discovering android Jetpack Compose (and Navigation) and try to display a preview of a view with a navController as parameter.
To achieve this, I use the PreviewParameter and I have no error, but nothing is displayed in the Preview window.
Does anyone know how pass a fake NavController instance to a Composable?
class FakeNavController : PreviewParameterProvider<NavController> {
override val values: Sequence<NavController>
get() {}
}
@Preview
@Composable
fun Preview(
@PreviewParameter(FakeNavController::class) fakeNavController: NavController
) {
HomeView(fakeNavController)
}
You don't have to make it nullable and pass null to it.
You just need to pass this: rememberNavController()
@Preview
@Composable
fun Preview() {
HomeView(rememberNavController())
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With