4

I have switched from Material 2 to Material 3 in my android compose project :

I have this dependencie which is the latest stable one :

implementation ("androidx.compose.material3:material3:1.0.1")

As mention in the docs i should be able to import and use the ModalBottomSheet :

https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#ModalBottomSheet(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.material3.SheetState,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,kotlin.Function0,kotlin.Function1)

But i get unresolved reference when importing :

import androidx.compose.material3.ModalBottomSheet

All my others M3 components are fine.

Can anyone help me on how I can import ModalBottomSheet without problem ?

loic .B
  • 281
  • 2
  • 11
  • check out this, it seems something like your question https://stackoverflow.com/questions/72518262/how-to-implement-bottomsheet-in-material-3-jetpack-compose-android – Rob Feb 13 '23 at 19:48
  • I have seen similar questions but it seems that google have added bottomSheet to the library since then because it is present in documentation with example.. I just dont get why my import (which is the same as the one in the sample) wont work.. – loic .B Feb 13 '23 at 20:03
  • Material3 implementation for the ModalBottomSheet was added to androidx.compose.material3:material3:1.1.0-alpha06. You won't find it the stable release yet. – Jack Feb 13 '23 at 20:38

2 Answers2

6

You need to use Version 1.1.0-alpha06 of Material 3 as this is a very recent addition. Please have a look at the release notes here.

Code Poet
  • 6,222
  • 2
  • 29
  • 50
0

You need to update the compose-bom to latest version in gradle module level file like this:

implementation(platform("androidx.compose:compose-bom:2023.08.00"))

currently the latest version is 2023.08.00 when ever you want it change it according.