There shouldn't be any issues in having just one state, because both JetpackCompose and SwiftUI are very well optimized for detecting changes.

You can nest the state information of each screen inside the overall state. For example, you can have data classes for each screen, which are just properties of the overall state.

The AppState is simply retained by the StateFlow. You don’t need to use onSavedInstanceState. Everything really works out very clean. Your single source of truth is the AppState hold by the StateFlow.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store