Sivan
09/01/2020, 7:01 AMContextAmbient.current
but android studio is unable to generate the error message.
So I ended up using the context like this
val context = ambientOf { ContextAmbient } as Context
But when I fire the intent, the app crashes with the following error.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sivan.pinotes, PID: 25739
java.lang.ClassCastException: androidx.compose.runtime.DynamicProvidableAmbient cannot be cast to android.content.Context
at com.sivan.pinotes.MainActivityKt$extendedFAB$2$1.invoke(MainActivity.kt:65)
at com.sivan.pinotes.MainActivityKt$extendedFAB$2$1.invoke(Unknown Source:0)
at androidx.compose.foundation.ClickableKt$clickable$2$tap$1.invoke(Clickable.kt:79)
If DynamicProvidableAmbient cannot be cast to a Context, are there any alternatives to this approach?Manuel Wrage
09/01/2020, 7:23 AMContextAmbient.current
Sivan
09/01/2020, 7:26 AM1.0.0-alpha01
btwSaurabhS
09/01/2020, 7:37 AMcurrent
property is a Composable while the onClick lambda isn't. You have to call it outside onClick. Something like val context = ContextAmbient.current
and then use the context in onClick.Sivan
09/01/2020, 7:44 AM