SmartToolFactory / Jetpack-Compose-Tutorials

🚀🧨📝 Series of Tutorials to learn about Jetpack Compose with subjects Material Widgets, Layout, SubcomposeLayout, custom layouts, State, custom rememberable, recomposition, LaunchedEffect, side-effects, Gesture, Animation, Navigation, Canvas, UIs like whatsapp and others.
Apache License 2.0
3.01k stars 312 forks source link

Tutorial 2.10.1 - Fix Broken Preview #44

Closed shahzadansari closed 7 months ago

shahzadansari commented 7 months ago

Preview was crashing with exception

java.lang.IllegalStateException: The offset was read before being initialized. Did you access the offset in a phase before layout, like effects or composition?
    at androidx.compose.material.AnchoredDraggableState.requireOffset(AnchoredDraggable.kt:344)
    at androidx.compose.material.BottomSheetState.requireOffset(BottomSheetScaffold.kt:230)
    at com.smarttoolfactory.tutorial1_1basics.chapter2_material_widgets.Tutorial2_10_1BottomSheetKt.MainContent(Tutorial2_10_1BottomSheet.kt:115)

Defaulted to Offset.Zero if BottomSheetState.offset was not initialized by the time it was read in Preview.

Screenshot 2024-03-05 at 10 17 11 PM