Passare argomenti e deep link
Trasferire i dati tra le destinazioni in sicurezza
Passare argomenti e deep link è una lezione Kotlin Multiplatform Academy gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Kotlin Multiplatform Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Kotlin Multiplatform Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Screens Need Data
A details screen has to know which item to show. Arguments are how one screen tells the next exactly what to display. 📦
Put the Value in the Route
You declare a placeholder right inside the route string. Curly braces mark where a value will be slotted in.
composable("details/{itemId}") { entry ->
DetailsScreen(entry)
}Read the Argument
Inside the destination you pull the value from the back stack entry. It arrives as a string you can use right away.
val itemId = entry.arguments?.getString("itemId")Pass a Value When Navigating
To send data you simply build the real route with your value inside it, then navigate to that string.
navController.navigate("details/42")Type-Safe Arguments
You can declare an argument as an Int instead of a string, so the framework parses and validates it for you.
composable(
"details/{itemId}",
arguments = listOf(navArgument("itemId") { type = NavType.IntType })
) { /* ... */ }Optional Query Arguments
Some values are optional, like a search filter. You add them as query parameters after a question mark in the route.
navController.navigate("search?query=kotlin")What Is a Deep Link
A deep link is a URL that opens a specific screen directly, even from outside the app. It maps a link to a route.
Register a Deep Link
You attach a deepLink pattern to a destination. When that URL arrives, navigation jumps straight to this screen.
composable(
"details/{itemId}",
deepLinks = listOf(navDeepLink { uriPattern = "myapp://details/{itemId}" })
) { /* ... */ }Deep Links Carry Arguments Too
The same placeholders work in a deep link URL. The itemId from the link lands in your back stack entry like any argument.
Platforms Wire Links Differently
Android and iOS each register your URL scheme in their own config, but both then hand the link to the shared graph. 🔗
Keep Arguments Small
Pass an id, not a whole object. Let the destination load its own data from the id, so routes stay tiny and reliable.
Quick Check
How should you typically send a complex object to the next screen?
Recap: Data and Direct Links
You sent arguments through routes, read them on the next screen, and mapped a deep link URL straight to a destination. 🎯
Domande Frequenti
La lezione «Passare argomenti e deep link» è gratuita?
Sì — il testo completo di «Passare argomenti e deep link» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Kotlin Multiplatform Academy, passa a CoddyKit PRO. Il corso Kotlin Multiplatform Academy include 4 lezioni in totale.
Cosa imparerò in «Passare argomenti e deep link»?
Trasferire i dati tra le destinazioni in sicurezza Eserciti Kotlin Multiplatform Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Kotlin Multiplatform Academy?
Non è richiesta alcuna esperienza precedente. Kotlin Multiplatform Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.
Quanto tempo richiede la lezione «Passare argomenti e deep link»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Kotlin Multiplatform Academy?
Sì. Ogni lezione Kotlin Multiplatform Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Navigare tra schermate condivise
- Passare argomenti e deep link
- Immagini, font e stringhe condivisi
- Localizzare il testo dell'interfaccia condivisa