I want to show a BottomSheetDialogFragment in immersive mode. Originally the nav and status bar would show when the dialog is displayed, but I can get that sorted with the code below. However, when the dialog is shown, or dismissed, the nav bar flashes for a split second. Is there a way I can show the BottomSheetDialogFragment fully immersive, without the nav bar flashing on show and dismiss?
abstract class ImmersiveBottomSheetDialogFragment<T : ViewDataBinding> : BottomSheetDialogFragment() {
    protected lateinit var binding: T
    private val systemUiVisibility: Int = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            or View.SYSTEM_UI_FLAG_FULLSCREEN
            or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
    fun showImmersive(
        fragmentManager: FragmentManager,
        tag: String,
        tapOutsideEnabled: Boolean = false
    ) {
        show(fragmentManager, tag)
        fragmentManager.executePendingTransactions()
        dialog?.let { dialog ->
            dialog.setCanceledOnTouchOutside(tapOutsideEnabled)
            dialog.window?.let { window ->
                window.decorView.systemUiVisibility = systemUiVisibility
                window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
            }
        }
    }
}
 
    