Closed uberchilly closed 1 year ago
@uberchilly hello, according to the code in the fragment state changer, the Fragment should only be removed if the key is not found in the previous list.
if(!newKeys.contains(oldKey)) {
So I would double-check if the key has equals()
implemented correctly. (is your ScreenX
class a data class
?)
It is not data class because it has no params. It is required for data class to have at least 1 primary constructor param.
It works when I set it to be data class @Parcelize data class ScreenX(val unused: String = "") : DefaultFragmentKey()
tnx.
Yeah it's unfortunate to have to specify that placeholder (I've been using the same approach for a long time now), I hear that data object
will be supported eventually is supported in Kotlin 1.7.20, so if Compose isn't binding you to use 1.7.10, you can actually use 1.7.20 and data object
instead of the unused param.
If you have a history of ScreenX and you run
backstack.setHistory( History.of(ScreenX()), StateChange.REPLACE )
old fragment gets removed but the new one is not added.