Hi <@UHAJKUSTU> . ```private val navigation = Stac...
# decompose
s
Hi @Arkadii Ivanov .
Copy code
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
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 }) { 
        ...
    }
}
But your can also do it during the navigation:
Copy code
navigation.navigate { stack ->
    // Check the current stack and return a new stack
}
Or maybe some of the existing operators will work, e.g.
bringToFront
.
s
Thanks @Arkadii Ivanov 😀
151 Views