I'm trying the new jetpack library "compose-navigation".
According to the docs, to navigate to a route, I should use navigate()
method which takes a String.
navController = rememberNavController()
// navigate
navController.navigate("/another_route")
However, no such method exists navigate(String)
and I get compile error.
What am I missing?
navigate(String)
is not part of NavController
class, but an extension function
To solve the error, "import the function route in the file":
import androidx.navigation.compose.navigate
// and then navigate
navController.navigate("/another_route")
And it'll work fine.
Unfortunately, you don't get the completion that you expect.
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