Closed grgkro closed 1 year ago
Thanks for looking into it @ItsAkashS22, I solved it now, the function onBleStatusChange() was called in the another function, which was called from within the build() function of also again another Screen, that was too much. I had to wrap everything with WidgetsBinding.instance.addPostFrameCallback()
then it worked. In the end this solved it:
@override
Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) {
QuickAlert.show(
context: context,
type: QuickAlertType.success,
title: 'Box geöffnet!',
text:
'Bitte entnimm jetzt die ${this.boxesController!.currentItem.value.name}',
confirmBtnText: 'Weiter',
onConfirmBtnTap: () async {
_navigateToTestDeviceUI();
);
});
...
Hello @grgkro 👋 This package is built for simple, quick & easy usage. You can use this package like this to solve your error.
QuickAlert.show(
context: context,
type: QuickAlertType.confirm,
title: "...",
text: "...",
onCancelBtnTap: () => false, // Set Cancel As False
onConfirmBtnTap: () => true, // Set Confirm As True
).then((value) {
if (value) {
// Navigate To Other Screen
} else {
// Do Other Action If Required
}
});
I hope this code snippet solves your problem. Happy Coding 🙌
https://stackoverflow.com/questions/74840292/navigator-inside-quickalert-dialog-does-not-work
In flutter, I have this Screen deep down in my MaterialApp's widget tree:
I get this error meassage after apping on the confirm button in the QuickAlert dialog
onConfirmBtnTap
:I also tried to add a small delay and to move the Navigation to a separate function:
But the error was the exact same. I also tried passing the BuildContext into that new separate Method instead of getting it from GetX, but it's the same error. I also tried to navigate with GetX
Get.to(() => MyNextScreen())
instead of using the Navigator, but that made no difference.I also asked ChatGPT3, it gave a good looking response that I should separate it into a separate function, but I think that makes no sense and the error stayed the same.