I\'m using a navigation-component in my application and also using shared ViewModel between multiple fragments that are in the same graph. Now I want to instantiate the View
...we should inject objects ( ViewModel,..etc ) in onAttach...
Looks like it is currently a no go for such injection with the original by navGraphViewModels(R.id.nav_graph)
delegated property provided by androidx.navigation
package because from the source code
findNavController().getBackStackEntry(navGraphId) and
public final NavController getNavController() it stated that:
* Returns the {@link NavController navigation controller} for this navigation host. * This method will return null until this host fragment's {@link #onCreate(Bundle)}
And here are some workarounds:
https://github.com/InsertKoinIO/koin/issues/442