'How to dismiss BottomSheet from within its Fragment
I am inside a Fragment(BottomHomeFragment) which is contained in (BottomSheetContainer) which is contained in activity (MainActivity)
I have tried to to dismiss she bottom dialog as follows but I get an exception
java.lang.IllegalStateException: Fragment BottomSheetContainer{707ddd6 (b95cd471-2647-41e5-a5a3-03f01db79e69)} not associated with a fragment manager.
Atttempt
val bottomSheet = BottomSheetContainer()
val metrics = DisplayMetrics()
CoroutineScope(Dispatchers.IO).launch {
requireActivity().windowManager?.defaultDisplay?.getMetrics(metrics)
if (loaded == true) {
bottomSheet.dismiss()
loaded = false
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
