In this tutorial I’ll show you how to pass data between to fragments using the safe args plugin inside Navigation component.
Safe Args, generates code that contains type-safe classes and methods for each action as well as with each sending and receiving destination.
If you don't know how Navigation works please watch my first video on Navigation
First part tutorial on Android Navigation and Fragment - [ Ссылка ]
For using Safe arg-
Add below dependencies at your Project level gradle inside dependencies block -
def nav_version = "2.1.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
Add below dependencies at your module level gradle on the top -
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'kotlin-kapt'
for details on dependencies : [ Ссылка ]
Navigation safe args is used to pass data between destinations. Navigation safe args helps to pass data between activities and Fragments easily and safely
We have covered -
Get started with the Navigation component
How to pass arguments to a fragment using bottom navigation view and Android Navigation component
Pass safe-args when navigate to fragment
Navigation Component: pass safeArgs from activity to a fragment
Navigation Safe Args using kotlin
Android Navigation Safe Args to pass data between Fragments in kotlin
Full Project : [ Ссылка ]
Ещё видео!