How to show composable like `Box` for few seconds ...
# compose
r
How to show composable like
Box
for few seconds and make it disappears.
c
With whatever state is driving your UI
Copy code
@Composable
fun SomeUi(showBox: Boolean) {
  // ...other UI code
  if (showBox) Box()
  // ...other UI code
}
If you wanted to hack something together quickly that would display for 2 seconds on first composition, you could write something like
Copy code
@Composable
fun SomeUi() {
  var showBox by remember { mutableStateOf(true) }
  LaunchedEffect(Unit) {
    delay(2_000)
    showBox = false
  }

  if (showBox) Box()
}
👍 4