Learn Android Development
Load Fragments in Jetpack Compose: Beyond What Google Taught
An experience from unworkable solutions to a solution that can load, pop, and restore fragments as needed.
We know Jetpack Compose is the future. But many of our Apps are still having Fragments. We cannot migrate everything over all at once. So we should do using an incremental approach.
One way is to do it bottom-up, where we migrate all the bottom components to Jetpack Compose, then only slowly we change the top part.
The other approach is to do it top-down.
In this writing, we’re focusing on the top-down approach. Therefore it is necessary for us to learn how can Jetpack Compose loads Fragments.
Initially, we think this is kind of impossible, as Fragments do have a lifecycle, etc. But after some further exploration, this is proven feasible!