Screen and PopResult are no longer Parcelable
Screen and PopResult no longer extend Parcelable on Android. Apps upgrading to this release should choose the persistence strategy that fits each type
-
Already using kotlinx-serialization?
- Keep the existing
SerializableCircuitSaverorReflectiveSerializableCircuitSaversetup. Remove@Parcelize, and useScreenorPopResultdirectly instead of the Parcelable marker interfaces.
- Keep the existing
-
Keep Android Parcelable persistence?
- Retain
@Parcelizeand change the type to implementParcelableScreenorParcelablePopResult. The registry-backed default saver accepts these types on Android.
- Retain
-
Migrate gradually?
-
Put the serializing saver first and retain the registry-backed saver as a fallback for Parcelable types:
val circuit = Circuit.Builder() .setCircuitSaver { fallbackSaver -> serializableSaver + fallbackSaver } .build()
-
-
Do not persist navigation state?
- Configure
CircuitSaver.NoOp. Restored stacks start again from their initial value.
- Configure
See Saving navigation state for complete setup and migration examples.
Saving an unsupported value now fails instead of silently dropping it. To intentionally drop values that no earlier saver supports, append CircuitSaver.Dropping { value -> ... } to the saver chain. Use CircuitSaver.NoOp as the final saver when dropped values do not need to be reported.
New
rememberDefaultCircuitSaver()creates a saver backed by the current ComposeSaveableStateRegistry.CircuitCompositionLocals(circuit)uses it automatically when no static or inherited saver is available.- Combine
CircuitSaverinstances with+. Savers are tried from left to right, and the first saver that supports a value owns the save or restore operation. Circuit.Builder.setCircuitSaver { fallbackSaver -> ... }combines an app saver with the saver inherited from the composition or created from its registry.- Custom savers can override
canSaveandcanRestoreto participate in a composite.
Removed
- Removed
DefaultCircuitSaver.CircuitCompositionLocals(circuit)now creates a registry-backed saver when needed. CallrememberDefaultCircuitSaver()when a saver must be passed explicitly. - Removed the deprecated companion
Saverproperties fromSaveableBackStackandSaveableNavStack. Use theSaver(CircuitSaver)functions.
Fixed
- Fixed R8 failures in apps using
@CircuitSerializableor@CircuitInjectwithout Hilt on the runtime classpath.
What's Changed
- Update dependency pymdown-extensions to v11.0.2 by @slack-oss-bot in #2858
- Update agp to v9.3.2 by @slack-oss-bot in #2859
- Remove Parcelable supertype from Screen and PopResult by @ZacSweers in #2849
- Update actions/setup-java action to v6 by @slack-oss-bot in #2862
- Update roborazzi to v1.73.0 by @slack-oss-bot in #2861
- Flesh out nav state docs by @ZacSweers in #2863
Full Changelog: 0.37.1...0.38.0