'Flutter Getx dialog utility Get.defaultDialog(), onCancel: () is not working properly

In a Flutter application, I'm using Getx package. In the project, Getx dialogue utility Get.defaultDialog() is used to show a confirmation. I want to route to a new screen if the user presses on Cancel button. For I have written the routing logic in onCancel: (). This navigation is not working properly.

following is the code snippet from the controller

 onCancel: () {
        //set flag
        GetStorage().write('DEBIT_CARD_TOP_UP_SAVE_CARD', false);
        //navigate to ipay88 gateway webview
        Get.toNamed(Routes.IPAY88_WEBVVIEW,
            arguments: ipay88gateWayPassRequest);
      },

and in the logs, I'm getting following when I click the cancel button

D/EGL_emulation( 3979): app_time_stats: avg=367.30ms min=15.68ms max=4854.00ms count=14 [GETX] OPEN DIALOG 367260191 D/EGL_emulation( 3979): app_time_stats: avg=223.97ms min=10.12ms max=3883.77ms count=19 [GETX] GOING TO ROUTE /debit-card-top-up/ipay88-webvview [GETX] CLOSE TO ROUTE /debit-card-top-up/ipay88-webvview

Ideally, it should not call the [GETX] CLOSE TO ROUTE.

any help is much appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source