Тёмный

Send Arguments between Screens | Navigation in Jetpack Compose 

Stevdza-San
Подписаться 84 тыс.
Просмотров 30 тыс.
50% 1

🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN
stevdza-san.com
🐱‍👤 Wanna become a member? Join!
/ @stevdzasan
📸 Instagram
/ stevdza_san
I'm going to continue my Navigation Compose tutorial series. And in this current video you'll learn how to pass single and multiple arguments using both argument types like Required and Optional arguments. This is a very important video in this series so I highly suggest you to watch the whole video. :)
Navigation Compose Playlist: • Navigation in Jetpack ...
⌚Timestamps
0:00 - Introduction
2:19 - Single Required Argument
8:13 - Multiple Required Arguments
10:36 - Single Optional Argument
14:03 - Multiple Optional Arguments
17:08 - Conclusion

Опубликовано:

 

8 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 74   
@lucasrubio7664
@lucasrubio7664 8 месяцев назад
I've been fighting with my code all afternoon, not knowing why it gave me errors when trying to passs variables from one screen to another. I came across your video and it was a life saver, I swear. The project I am developing is for college and I had to finish it literally this afternoon. You saved me, thank you so much! Great video and great explanations, cheers from Spain dude :)
@siarheisudakou4455
@siarheisudakou4455 2 года назад
Excellent lesson! Thanks a lot! Looking forward for the next tutorial:]
@StevdzaSan
@StevdzaSan 2 года назад
Thank you! 🙌 More to come.
@zoompartyru
@zoompartyru 2 года назад
Thanks a lot! Excellent!
@sanjaikumar7706
@sanjaikumar7706 2 года назад
Bought all your courses on Udemy and developing myself everyday !!!! Thanks Steve!! You're the best in android !!
@StevdzaSan
@StevdzaSan 2 года назад
Awesome! Keep working on your personal projects as well. 👌👍
@pawechilczuk7559
@pawechilczuk7559 6 месяцев назад
Very complicated way... I hope it will be simplified soon. For me was much easier with Bundles. But video of course helpful.
@GriNAME
@GriNAME 2 года назад
Compose is so cool stuff! Thanks you for your another tutorial
@StevdzaSan
@StevdzaSan 2 года назад
Yeah it is! 🚀
@mystride
@mystride 2 года назад
Its 2022 and Android went back to 1992 HTML navigation. It's dystopian.
@xenatronics393
@xenatronics393 2 года назад
I follow you on Udemy. Your courses are amazing!! Well explained!!
@StevdzaSan
@StevdzaSan 2 года назад
Thanks Sarah! 👊
@funnymoment9164
@funnymoment9164 2 года назад
Thanks!
@tellator
@tellator 3 месяца назад
Very clear and detailed. Thank you very much
@StevdzaSan
@StevdzaSan 3 месяца назад
You're welcome 😊
@kennethmallari127
@kennethmallari127 2 года назад
defaultValue arguments of NavGraph cant override the default value arguments you set on the sealed class?
@hussein9577
@hussein9577 2 года назад
Great tutorial as usual
@mi8377
@mi8377 2 года назад
Best content for Android devs, especially beginners.
@StevdzaSan
@StevdzaSan 2 года назад
Thanks! ❤😊
@thegreatwarrior4989
@thegreatwarrior4989 2 года назад
Your explaition is perfect 👍👍👍👍✊✊✊👍👍👍👍
@StevdzaSan
@StevdzaSan 2 года назад
Thank you! 🙏
@frankyjunior6005
@frankyjunior6005 2 года назад
how about if I have Screen A -> B -> C, then when C it will back to A with passing arguments so back to A it will have value from C
@digitalluxury2033
@digitalluxury2033 2 года назад
amazing as usual
@StevdzaSan
@StevdzaSan 2 года назад
Thanks 💜
@digitalluxury2033
@digitalluxury2033 2 года назад
@@StevdzaSan I hope if you have update function to upload images to server >>>> like localhost .... or is it available in your online courses?
@mohammadamirkanjoori138
@mohammadamirkanjoori138 Год назад
nice
@duyhyhoangcong9226
@duyhyhoangcong9226 2 года назад
Thanks a lot 🤗🤗
@StevdzaSan
@StevdzaSan 2 года назад
👌👊
@ajay-ri7ex
@ajay-ri7ex 2 года назад
What is the best way to pass bitmap between composoble screens
@stendoff2388
@stendoff2388 2 года назад
Great lesson, thanks. And how can I get the sent values for further work with them?
@sooshil
@sooshil Год назад
For example, if you need that id in Detail Screen, then the detail screen composable should expect it. DetailScreen(id: Int) Then just below the log statement, when you call DetailScreen, you can pass the id to the constructor.
@deceptivelysmallman
@deceptivelysmallman Год назад
@@sooshil Amazing thank you! Really useful ^^
@gara7723
@gara7723 7 месяцев назад
@@sooshil I'm sorry I don't understand. I setup my composable like this: @Composable fun DetailScreen( navController: NavController, id: Int ) {...} Then in the NavGraph.kt file what exactly do I need to pass for the id? DetailScreen(navController = navController, id = )
@nadersada8453
@nadersada8453 10 месяцев назад
can we use a custom class as argument?
@youprimeprime3046
@youprimeprime3046 2 года назад
Awesome
@StevdzaSan
@StevdzaSan 2 года назад
Thanks 👊
@WilliamLindblom
@WilliamLindblom 2 года назад
Doesn't the use of default values in the passNameAndId() function make the usage of optional parameters redundant? It will always pass a value, so the params might as well be required as the "optionality" lies in the default values of the function. Or am I missing something?
@StevdzaSan
@StevdzaSan 2 года назад
Yep that's correct. However 'optional' in that case would be not calling that function at all. And just navigating to the default route. :)
@hemantp66
@hemantp66 Год назад
why log is called 3 times , when you click once?
@abada-s
@abada-s 2 года назад
we can always use required arguments and specify optional arguments in the Screen method declaration is it true?
@StevdzaSan
@StevdzaSan 2 года назад
Yes if you add default parameters
@jatinvashisht4293
@jatinvashisht4293 2 года назад
Amazing series 👏 At the same time I want it How can we pass non primitive data types like list or array?
@StevdzaSan
@StevdzaSan 2 года назад
You can pass an Array.
@jatinvashisht4293
@jatinvashisht4293 2 года назад
@@StevdzaSan okay, thanks for clarifying 🙏
@aishwaryabhishek1822
@aishwaryabhishek1822 2 года назад
2 questions , why are the logs getting printed 3 times ? is it getting recomposed that many time ? And how to pass Parcelable objects . Great content though
@StevdzaSan
@StevdzaSan 2 года назад
We don't have a much control over a re-composition process in general. "A composable function might be run quite frequently, as often as every frame of an animation." Passing a Parcelable object is not recommended. You have already seen the route structure of one screen and it's arguments. The common practice is to just pass some primitive values like id's and then from the other side, get that id and fetch the data you need(From database or even an API).
@easybusinessou
@easybusinessou 2 года назад
@@StevdzaSan sometimes we have already fetched object we only need to display in another composeable
@StevdzaSan
@StevdzaSan 2 года назад
@@easybusinessou My suggestion would be to reconsider the logic of your app, and modify it in a way to have only primitive types passed as arguments. Also if you need to save some kind of object, consider adding a Shared ViewModel.
@aishwaryabhishek1822
@aishwaryabhishek1822 2 года назад
@@StevdzaSan Thats a step back from current Navigation library dont you think ? I think its better to still use the current navigation and each fragment just hosts a composeView .
@markdelphi8075
@markdelphi8075 Год назад
Thanks for lesson. Is it possible to send a Data class like data class Car(val model:String, val color: Int) as an argument? Thanks .
@StevdzaSan
@StevdzaSan Год назад
I've made a video about passing a parcelable object, check my Jetpack Compose playlist.
@pyaesonehan19
@pyaesonehan19 2 месяца назад
@TP-rn2gm
@TP-rn2gm 5 месяцев назад
does anyone know how to stop print the log 3 times by 1 click ?
@alij3fer
@alij3fer 2 года назад
Thanks sir , next video you well show how can put/get parcelable /serializable type class?
@StevdzaSan
@StevdzaSan 2 года назад
I'll think about it, however that's not a good practice anymore. :) Read the reply which I've posted on @Aishwary Abhishek comment.
@ultimat.
@ultimat. 2 года назад
Components navigation top top +++++ news
@kubux6426
@kubux6426 2 года назад
Can I pass data object as argument?
@StevdzaSan
@StevdzaSan 2 года назад
That's not a recommended approach. Instead you need to pass primitive values, like for example only the ID of a certain object, which can be then retrieved on the other side from another screen.
@tusharbhart4105
@tusharbhart4105 2 года назад
Is there any way to send data between the fragments without actually navigating to that fragment?
@StevdzaSan
@StevdzaSan 2 года назад
Use Shared ViewModel for that. Or even persist the value with DataStore/ROOM DB.
@easybusinessou
@easybusinessou 2 года назад
@@StevdzaSan please make next video for this
@mehmettekin9142
@mehmettekin9142 2 года назад
But, how to get "id" in the Detail Screen
@TriNguyen-ym3hf
@TriNguyen-ym3hf 2 года назад
Passing id to detail screen as parameter, like 5:23, put id right after navController
@siva_subramaniam
@siva_subramaniam Год назад
Bm - 10:36
@pritamdas2232
@pritamdas2232 2 года назад
why log printed 3times??
@StevdzaSan
@StevdzaSan 2 года назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-O6zNcV3PaJE.html
@pritamdas2232
@pritamdas2232 2 года назад
@@StevdzaSan thanks
@Miasdsadas
@Miasdsadas 3 месяца назад
Is there any other way to pass an object? Passing by string like this is annoying
@manofsteel6173
@manofsteel6173 2 месяца назад
it was very fast.i didnt get it :(
@ecoskun87
@ecoskun87 9 месяцев назад
too many code for a basic thing. I dont like android.
@igormorozov6311
@igormorozov6311 Год назад
Thanks!