flutter_cool_alert icon indicating copy to clipboard operation
flutter_cool_alert copied to clipboard

AutoCloseDuration causing multiple renders of popup.

Open Vargas-E opened this issue 1 year ago • 0 comments

CoolAlert.show(
              context: somekey.currentContext!,
              type: CoolAlertType.error,
              title: e.response?.statusCode != 200 ? "Server error" : "Device Error",
              text: "error text",
              autoCloseDuration: const Duration(seconds: 5),
              backgroundColor: Colors.red,
              barrierDismissible: true,
              width: 400,
              confirmBtnColor: Colors.red,
            );```

I was using coolAlert just like this and i noticed that when this triggers, the alert pops up several times (from 10 to 30 times).  I initially thought that this was happening because with each rerender of the currentContext widget the alert triggered again. 

I compared the implementation changing the coolAlert for a simple Showdialog with an AlertDialog and it worked properly. That got me thinking about how the coolAlert.show is a future and that would be the main difference with an AlertDialog. I commented the autoCloseDuration and it worked fine, just showing it once.

Currently i'm using it without the autoCloseDuration, but it would be nice if this could be checked.

Apologies in advance for any english grammar mistake, english is not my native language.

 

Vargas-E avatar Apr 01 '24 19:04 Vargas-E