https://kotlinlang.org logo
#android
Title
# android
c

chanjungskim

02/28/2023, 9:06 AM
How can I send
surveyToken
here to ResultScreen?
Copy code
surveyScreen(
    moveToResult = { surveyToken ->
        navController.navigateToResult(surveyToken)
    }
)
And here's the navigateToResult function.
Copy code
const val resultRoute = "result_route"

fun NavController.navigateToResult(surveyToken: String, navOptions: NavOptions? = null) {
    this.navigate("$resultRoute/$SURVEY_TOKEN?=$surveyToken", navOptions)
}

@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.resultScreen(deviceDisplayState: DeviceDisplayState, moveToOrder: () -> Unit, moveToBack: () -> Unit) {
    composable(route = resultRoute) {
        ResultRoute(deviceDisplayState, moveToOrder, moveToBack, hiltViewModel(LocalContext.current as MainActivity))
    }
}
I get
Copy code
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=<android-app://androidx.navigation/result_route/survey_token?=711d28d33d0fd880459108da5aeb819fce94948f49bdbed20117a27c7109> } cannot be found in the navigation graph NavGraph(0x0) startDestination={NavGraph(0x22fb6594) route=entry_graph startDestination={Destination(0x2395568f) route=entry_route}}
this error.
d

Divyansh Kushwaha

03/01/2023, 4:16 AM
Copy code
this.navigate("$resultRoute/$surveyToken", navOptions)
Try this
7 Views