Lorenzo Benevento
09/04/2021, 11:56 AMBottomSheetScaffold
but as soon as you try to do the same thing with a ModalBottomSheetLayout
it throws java.lang.IllegalArgumentException: The initial value must have an associated anchor.
because you are initializing it with a null value. If you just swap the two or more contents instead of setting a null value when you close the ModalBottomSheet
it will work but it won't animate correctly.jossiwolf
09/04/2021, 12:08 PM@Composable fun App() {
var sheetContent: (@Composable ColumnScope.() -> Unit)? by remember { mutableStateOf(null) }
ModalBottomSheetLayout(sheetContent = sheetContent ?: { EmptySheet() }, ...)
}
@Composable fun EmptySheet() {
Box(Modifier.height(1.dp)
}
See https://issuetracker.google.com/issues/178529942
I'd advise using Accompanist Navigation Material instead though as it takes care of these things.Lorenzo Benevento
09/04/2021, 12:09 PMLorenzo Benevento
09/04/2021, 1:35 PM