Libor Bicanovsky
12/14/2021, 12:35 AMcondition?.let {
//some composable
} ?: //other composable
In 1.1.0-beta04 this will not work correctly and the second condition will never be evaluated/displayed.
It works correctly in previous versions (such as 1.0.5). Just wanted to mention it since it caught us out!Zach Klippenstein (he/him) [MOD]
12/14/2021, 1:23 AMLibor Bicanovsky
12/14/2021, 2:05 AMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
Greeting(null)
}
}
}
}
}
@Composable
fun Greeting(name: String?) {
name?.let {
Text(text = "FIRST")
} ?: Text(text = "SECOND")
}
let
with also
Chris Fillmore
12/14/2021, 10:15 AM