After updating to compose 1.7, I notice the Materi...
# compose
m
After updating to compose 1.7, I notice the Material 3
ModalNavigationDrawer
very briefly (maybe 100ms or so) flashes up on the screen. What could be causing this?
So the issue happens when
setContent
(usually called from
onCreate
) is actually called a little later. In my app, I collect a startup-state flow and call
setContent
when a success state is reached. You can simulate this with:
Copy code
// simulate waiting for some startup event to complete
GlobalScope.launch(Dispatchers.Main) {
    delay(1.seconds)
    setContent {
        AppTheme {
            ModalNavigationDrawer(
                drawerContent = {
                    ModalDrawerSheet {
                        ...
                    }
                }
            ) {
                ...
            }
        }
    }
}
So, is this a bug or WAI?
Nasty workaround is to apply an alpha like this:
Copy code
var drawerAlpha by rememberSaveable {
    mutableFloatStateOf(0f)
}
LaunchedEffect(Unit) {
    delay(500.milliseconds)
    drawerAlpha = 1f
}
ModalDrawerSheet(
    modifier = Modifier.alpha(drawerAlpha),
    ...