I am trying to fire an intent to move to the next activity when I click on an ExtendedFloatingActionButton. To obtain the context, I tried
ContextAmbient.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?