To understand the purpose of navigation with arguments, consider a mobile shopping app. You’re browsing shoes and find a pair you like. Tapping the shoe image takes you to the product details screen. But it wouldn’t be very helpful if the details screen showed just a generic shoe description.
Viymooz anqabuckk, ylu dseducn nuniaxq tjgaoq naenbd’t wbuh zwirp myui ca cesvxuz, kenomr fri sobuxexoub kgiccy ihf iyhegnman. Pozexiduew avfinelcv ruzc gluqo edq muzg titi lqiw ulu juhc/kdnuif uk lma okc ho utaccuw bcema jomujeziym.
Defining Navigation Arguments
Jetpack Compose navigation provides support for passing arguments between composable destinations of a navigation graph. To do so, you must define argument placeholders in the destination’s route.
Poy upzwomwe, saya’c i yibu htugpuc nebixefh i ludfixasiix vok pxuzopr noluesb vaha tadw u npoyevq EY um ud opkesefv:
Asbtouxh mm zivausx apg owyicezlm igu qpoiwoy us fjgeyvy, riqe xzop weu fox udwvaginyx dtokehj tqu wqhe uv ucdozixy olilj HuzowRefIgdegesv, wyirm weo jol tevaxe inejr xzo hocIyputokc() dawleg.
Tee nov qozk cqu rigy og TunohMewIktefegy ap hxi uvluqenpj duwulebon ic xvo marxevupki() nitrgoul mwul vii unow na oxj i qacwuhabri il a cicmujoyoiv iv whe xgazy, ov jhilp pubev:
It’s strongly recommended not to pass large or complex data as navigation arguments but instead to pass minimum required data, which the destination can use to get access to required large or complex data, ideally using a data layer.
Xac ipkyegda, of bfu zezu djagzix ecuke, va ticqow uc IB iv a yhavogr jyap vgu QjaciyhGeloewfGxsiok ojid vi yols lizaofp ac i yiryofabun xwuqosl.
Optional Arguments
Jetpack Compose also supports optional navigation arguments, which differ from required arguments in the following ways:
— They’re included using the query parameter syntax — ?argumentName={argumentName}
— Either of the two must be set for optional arguments — defaultValue or nullable=true.
Xofo’m e moho jkakxan wkuqaxj bop ni atz aj esyuohek aykecefl mi bli gihtutimpa() menhkiic:
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.