For a custom data type we should override one more function in the NavType to avoid that run-time exception: serializeAsValue() and just return Json.encodeToString(value) ✅
You always find amazingly good content. Thanks for the effort you put into teaching us something new. My day is perfect when it starts with your videos. Thank you.
I always use a navigation viewModel to hold the data( also complex objects) and then read it from the destination screen. Use enum classes to define routes to overcome typing errors. This approach with compose navigation works well in every scenario.
Currently I'm taking Your course on Udemy ToDo App with Compose, and these string-based routes were strange to me. What a perfect time for this video to come out 😅
Bro still basic ui components are (Experimental) and has bugs for 3 year still they dont care it ? And why they still making shitshow apis intead of fix experimentals and stable it. Imagine getting type safe arguments after 3 years.I really dont understand them
Isnt it more convenient to convert custom object to Jsonstring and pass as string param then parse the 'Json to object instead of creating navtype boilerplate code? Pass Gson().toJson(yourModelClassObject) in string param, then for getting it use generic function: inline fun String?.parseJsonString(): T? { return try { this?.let { val type = object : TypeToken() {}.type Gson().fromJson(it, type) } } catch (e: JsonSyntaxException) { Log.i("Error", "Failed to parse JSON string: ${e.message}") null } } val screenA = it.toRoute() val data = screenA .jsonstring.parseJsonString()