The project is simple: Login screen and a forgot password screen. You can navigate from Login to ForgotPassword.

I feel like I overcomplicated things, but I don't know if (and how) it can be simplified.

The code: LoginRoute.kt

fun LoginRoute(
    viewModel: LoginViewModel = hiltViewModel(),
    navController: NavHostController,
) {
    val uiState by viewModel.uiState.collectAsStateWithLifecycle()

        uiState = uiState,
        onLoginClicked = {
        onForgotPasswordClicked = {


class LoginNavigationFactory @Inject constructor() : NavigationFactory {

    override fun create(builder: NavGraphBuilder, navController: NavHostController) {
        builder.composable(NavigationDestination.Login.route) {
            LoginRoute(navController = navController)
        builder.composable(NavigationDestination.ForgotPassword.route) {

Do I really need to pass navController as an argument to the Routes? If I don't do it and simply do rememberNavController in the composable, it gives me NullPointers.


1 Answer 1


I pass in a delegate and handle navigation at the top. I find this better practice


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.