Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetpack compose navigation popUpTo inclusive true not cleared composable screen from backstack

I am using Jetpack Compose ui version 1.3.0-beta08 and navigation compose version 2.4.0-alpha02 and working Bloom app with all new Architecture components. After login success I need to clear all previous compose login screens, but even added popUpTo("HomeScreen"){inclusive = true}, my login screen removed from backstack, but login welcome screen not removed from backstack, when I click back from Home screen. is it anything I am missing/wrong in compose navigation?

composable(Screen.LoginScreen.route) {
                LoginScreen {
                    Log.d("AppMainNavigation", "AppMainNavigation: ${navController.backQueue}")
                    navController.navigate(Screen.HomeBaseScreen.route){
                        popUpTo(Screen.LoginScreen.route){
                            inclusive = true
                        }
                        launchSingleTop = true
                    }
                }
            }

GitHub Link : https://github.com/rramprasad/BloomApp/blob/main/app/src/main/java/dev/ramprasad/bloom/MainActivity.kt

like image 466
Ramprasad Avatar asked Nov 07 '22 01:11

Ramprasad


1 Answers

update your jetpack compose version to the latest release preview version and all other dependencies. current jetpack composes version: 1.0.0-rc02

and also which screen you want to popup just use this

my splash screen code:

 @Composable
 fun Navigate(navController: NavController) {
    produceState(initialValue = -1) {
        delay(1500)
        navController.popBackStack()
        val route = if (Firebase.auth.currentUser == null) AppRouter.Intro.route else AppRouter.Home.route
        navController.navigate(route)
    }
 }

so here you can use this below line to remove screen from backstack

navController.popBackStack()
like image 134
Nafis Kabbo Avatar answered Nov 14 '22 22:11

Nafis Kabbo