Avoid return statements in Jetpack Compose!
<p>It’s not the cleanest code, but it works fine in general, and it saves you from dealing with that annoying <code>null</code> initial value for the state variable, right? Well, not so fast!</p>
<p>I’ve seen cases where code like this can result in that flow never getting new states, so, after that initial return, we never get a proper value to actually draw the screen we want. Even worse, after a configuration change, if anything tries to interact with the <code>navController</code> and that return triggers beforehand, it may lead to a crash, since its <code>navGraph</code> never got set by the <code>NavHost</code> .</p>
<p>Now, let’s move to a more subtle situation where I had issues with returns:</p>
<pre>
@Composable</pre>
<p><a href="https://medium.com/android-ideas/avoid-return-statements-in-jetpack-compose-9596deb2059f"><strong>Read More</strong></a></p>