belovance / QuickAlert

An instantly ready, full-featured alerts for development on any platform with flutter. Enabling you to complete projects and deploy quickly. With QuickAlert, you can display animated alert dialogs such as success, error, warning, confirm, loading or even a custom dialog.
https://pub.dev/packages/quickalert
MIT License
46 stars 42 forks source link

Now onConfirmBtnTap, onCancelBtnTap callback functions will return current context #28

Closed abhay-s-rawat closed 5 months ago

abhay-s-rawat commented 6 months ago

Solved problem where when writing custom onConfirmBtnTap , popping the alert causes the screen to pop as we are popping top level context.

// In below example the alert stays on screen in macos as the we are popping the top level context. Popping it causes current screen to pop.
QuickAlert.show(
              context: context,
              type: QuickAlertType.error,
              title: "Deny rewards ?",
              cancelBtnText: 'Back',
              showCancelBtn: true,
              showConfirmBtn: true,
              //autoCloseDuration: const Duration(seconds: 10),
              onConfirmBtnTap: () {
// Some custom code
                Navigator.pop(context);
              },
            )
//Solution
// With below code we can catch the result too, thus detecting wheather the closure of alert is done by cancel/ok button or barrier dissmissable.
var result = await QuickAlert.show(
              context: context,
              type: QuickAlertType.error,
              title: "Deny rewards ?",
              cancelBtnText: 'Back',
              showCancelBtn: true,
              showConfirmBtn: true,
              //autoCloseDuration: const Duration(seconds: 10),
              onConfirmBtnTap: (ctx) {
// Some custom code
                Navigator.pop(ctx, true);
              },
            )
abhay-s-rawat commented 6 months ago

Any idea when publisher will push this to pub dev ?

abhay-s-rawat commented 6 months ago

Any update on this ?

abhay-s-rawat commented 6 months ago

Any update on this ?

abhay-s-rawat commented 5 months ago

??

ItsAkashS22 commented 5 months ago

Hello @abhay-s-rawat

No need to take context into the function as a parameter, we can directly address/use the context of the parent.

Happy Coding!!!

abhay-s-rawat commented 5 months ago

If you try to pop eith parent context the current page gets popped not the dialog. I tested same in macos.