How can I pass argument to dialog fragment using the navigation architecture component safeargs? below is my current implementation
Start Fragment
val navController = findNavController()
val action =
QuestionListFragmentDirections.actionQuestionListFragmentToCustomDialogFragment(args.templateFlag)
navController.navigate(
action
)
Destination Fragment
args.templateFlage //supposed to return a boolean value
//but throws java.lang.IllegalStateException: Fragment QuestionTypeDialogFragment{e8be5e1}
(47b305ea-35b2-49e0-b378-d31a08ba9a41) QuestionTypeDialogFragment} has null arguments
May be you use args before fragment got it. For example I changed it in my code:
private val args by navArgs<RadioDetailFragmentArgs>()
private val stations = args.stations.toList()
with
private val args by navArgs<RadioDetailFragmentArgs>()
private val stations by lazy {
args.stations.toList()
}
And it works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With