https://kotlinlang.org logo
#compose
Title
# compose
s

Shakil Karim

01/30/2021, 11:48 AM
How can i do hide/Show Composable instead of if (someCondition) { ComposableA() } else { ComposableB() } Because using if-else I'm getting flicker when changing screens, Which is what I want to avoid.
a

Andrey Kulikov

01/30/2021, 1:56 PM
if you mean an animation you can try
Crossfade
s

Shakil Karim

01/30/2021, 2:56 PM
I am currently using Crossfade, but it create a new Composable ever time I switch, I guess i will try with Modifier.alpha()
j

jim

01/30/2021, 3:29 PM
Creating a new Composable won't be a problem if you hoist your state up. Then your function is a functional transform of data->UI and the maintaining of state (or lack thereof) becomes an unobservable implementation detail because all the state you care about is above the Crossfade widget.
👍 1
s

Shakil Karim

01/30/2021, 8:24 PM
Yup, i know creating new Composable is not an issue generally, but i have a screen which has images which is loaded from network. and when I switch between Composable it's shows placeholder for a sec. However images are cached as well.