feduke-nukem / flutter_easy_dialogs

Easy dialogs library for Flutter
https://pub.dev/packages/flutter_easy_dialogs
MIT License
13 stars 0 forks source link

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

Open dragongesa opened 2 months ago

dragongesa commented 2 months ago

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

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();
}
feduke-nukem commented 2 months ago

Hello @dragongesa

Could you provide code example?

dragongesa commented 1 month ago

@feduke-nukem

I've updated the description and method for this issue:

  1. Current behavior: Dialogs can be dismissed using navigator.pop(), router.pop(), or the .hide() method.

  2. Desired behavior: Dialogs should only be dismissible through the .hide() method.

  3. Problem: Using navigator.pop() or router.pop() currently dismisses the dialog, which is not the intended functionality.

  4. Proposed solution: Make dialogs immune to navigator.pop() and router.pop() methods. They should only respond to the .hide() method.

  5. Impact: This change will provide better control over dialog behavior and prevent unexpected dismissals in complex navigation scenarios.

Could you please review this updated description and consider implementing this functionality? It would greatly improve the predictability and usability of FlutterEasyDialogs in various navigation contexts.

Let me know if you need any additional information or clarification on this issue.

feduke-nukem commented 1 month ago

What type of dialog do you use? @dragongesa

Fullscreen or Positioned ?

dragongesa commented 1 month ago

@feduke-nukem hi, i tried it with FullScreen, not sure if the Positioned also have that issue

feduke-nukem commented 1 month ago

@feduke-nukem hi, i tried it with FullScreen, not sure if the Positioned also have that issue

Please try to pass androidWillPop argument into FullScreenDialog.

Let me know if it helps.