I'm using the Horologist sample to use wear naviga...
# compose-wear
t
I'm using the Horologist sample to use wear navigation compose with the pager to switch pages but this does not work correctly.
The horologist code is
Copy code
public fun getPageParam(backStack: NavBackStackEntry, remove: Boolean = false): Int? {
            val pageNumber = backStack.arguments?.getInt(page, -1) ?: -1
            if (remove) {
                backStack.arguments?.remove(page)
            }
            return if (pageNumber < 0) null else pageNumber
        }
But since the arguments are always copied and immutable you actually can't remove the parameter.
This maybe more a question for @Ian Lake, but as anyone have an idea about how I can ensure that if I navigate down then back the page param is not returned again to avoid unwanted page change.
y
Hmmmm, I'm sure it used to work. Good catch.
i
Arguments have been immutable since Navigation 2.6.0, back in June 2023: https://developer.android.com/jetpack/androidx/releases/navigation#2.6.0
Arguments should be a key part of the identity of the destination , not something you use to pass events, so there's probably a different way to approach this problem in general
Note that the SavedStateHandle, which is started with the same fields as the arguments, is mutable, so maybe that's a better place to do this logic without changing everything
t
Thanks for the details, I'm new to Jetpack navigation hence why I followed the Horologist approach. For direct navigation I can easily workaround. But for deep links since we can't build a stack I can't think of a way.