'Null NavHostController when using Dagger Hilt | Android Jetpack Compose
I have this screens structure in my app

RootComp is a composable with a NavHost containing Splash, Access and Main. Main contains a NavHost containing Ranking, Sales, Feed and Settings, which eventually can use RootComp's nav controller to navigate from Main to Access.
Each NavHostController is only linked to one NavHost.
I want to achieve being able of navigate with RootComp's NavHost from any child of Settings. The thing is I would like to achieve this without passing the nav controller to each composable. I want to have the nav controllers stored globally somehow.
I've tried using Dagger Hilt like this
@Module
@InstallIn(SingletonComponent::class)
object AppModule {
...
@Provides
@Singleton
@Composable
fun provideNavController() = rememberNavController()
...
}
But it gives me this error
error: [Hilt]
Null dependency: java.lang.NullPointerException: Null dependency
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
