The docs say I can create a `NavController` using ...
# compose
y
The docs say I can create a
NavController
using ``val navController = rememberNavController()`` . But when I create a navController this way I get
NavHostController
instead. It works fine for my
NavGraph
but I cannot use
.navigate()
on
NavHostController
. The docs do not include anything about the difference of these two or even mention
NavHostController
.
i
NavHostController
extends
NavController,
you automatically get any
NavController
based APIs
Make sure you've added the import for the navigate that takes a route
y
It does not show the import automatically. I have to find it manually and import it.
i
The last reported issue on this wasn't reproducible on the latest versions of Studio: https://issuetracker.google.com/issues/172834438
Make sure you're actually typing in a string -
navigate()
without any parameters is never valid (and wouldn't have any matching extension function to import)
The next release will be moving all of these extensions to be methods on the classes themselves (tracking bug https://issuetracker.google.com/issues/172823546), so it won't be an issue anymore
y
The screen shot does not have a string but its the same even with a String param
i
Then you should probably report a new bug in the Android Studio component
y
Okay, will do - I just added the import manually on my project for now as well