How can i do hide/Show Composable instead of if (s...
# compose
s
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
if you mean an animation you can try
Crossfade
s
I am currently using Crossfade, but it create a new Composable ever time I switch, I guess i will try with Modifier.alpha()
j
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
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.