Open
Description
FlutterEasyDialogs: Dialogs can be dismissed with navigator.pop or router.pop
Description
In the current implementation of FlutterEasyDialogs, dialogs can be dismissed using navigator.pop()
or router.pop()
. This behavior is undesirable as it allows dialogs to be closed through methods other than the intended .hide()
method. Dialogs should only be dismissible through the .hide()
method to ensure proper control and functionality.
Steps to Reproduce
- Set up a Flutter project using FlutterEasyDialogs
- Show a dialog using FlutterEasyDialogs
- Attempt to dismiss the dialog using
navigator.pop()
orrouter.pop()
Expected Behavior
The dialog should remain visible when navigator.pop()
or router.pop()
is called. It should only be dismissible through the .hide()
method provided by FlutterEasyDialogs.
Actual Behavior
The dialog is dismissed when navigator.pop()
or router.pop()
is called, bypassing the intended dismissal method.
Additional Information
- Flutter version: 3.22.3
- FlutterEasyDialogs version: 4.0.1
- Device/Emulator: Xiaomi Redmi Note 11 Pro
- OS: Android
Proposed Solution
Modify the FlutterEasyDialogs implementation to intercept or override the default pop behavior. This could involve:
- Using a custom route that ignores pop requests not originating from the
.hide()
method - Implementing a WillPopScope widget to prevent unintended dismissals
- Creating a custom Navigator observer to intercept and potentially cancel pop operations on dialogs
Minimal Reproducible Example
// Assuming FlutterEasyDialogs is properly set up
void showAndAttemptToDismiss() async {
await FlutterEasyDialogs.show(/* dialog configuration */);
// This should not dismiss the dialog
Navigator.of(context).pop();
// This should also not dismiss the dialog
router.pop();
// Only this should dismiss the dialog
FlutterEasyDialogs.hide();
}