Skip to content

[Bug]: FlutterEasyDialogs: Dialogs can be dismissed with navigator.pop or router.pop #32

Open
@dragongesa

Description

@dragongesa

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

  1. Set up a Flutter project using FlutterEasyDialogs
  2. Show a dialog using FlutterEasyDialogs
  3. Attempt to dismiss the dialog using navigator.pop() or router.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:

  1. Using a custom route that ignores pop requests not originating from the .hide() method
  2. Implementing a WillPopScope widget to prevent unintended dismissals
  3. 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();
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions