Is there any way to override onBackPress to go back to a screen with its index in jetpack compose? For example, go back to the second previous screen.
You can with backhandler function;
BackHandler(
enabled = //condition if you want.
) {
// Navigate where ever you want.
//Example;
navController.navigate(
route = navController.backQueue[i].destination.route.toString()
)
}