private val navigation = StackNavigation<Configuration>()
This in my navigation stack. I want to know Configuration at top of stack or if navigation contains a particular Configuration. Consider a scenario , my navigation stack contains {A,B,C,D,E}. now on button click it pushes 'B' again it causes error
"Uncaught Kotlin exception: kotlin.IllegalStateException: Configurations must be unique". TO solve this error i want to know if navigation contains this Config or not before psuhing.
I am ujsing "2.0.0-compose-experimental-alpha-02" as i am developing for ios
a
Arkadii Ivanov
07/12/2023, 1:22 PM
You can check the navigation state.
Copy code
private val _stack = childStack(...)
val stack: Value<ChildStack<*, Child>> = _stack
fun foo() {
if (_stack.items.any { it.configuration is Config.Something }) {
...
}
}
Arkadii Ivanov
07/12/2023, 1:23 PM
But your can also do it during the navigation:
Copy code
navigation.navigate { stack ->
// Check the current stack and return a new stack
}
Arkadii Ivanov
07/12/2023, 1:24 PM
Or maybe some of the existing operators will work, e.g.