-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
When the user confirms cancelling the task (showCancelConfirmationDialog), the navigator is
popped twice to close the cancel confirmation dialog and exit the task.
The task should only be exited if the closeAfterFinished is true, but is done unconditionally.
See line Navigator.of(context).pop(); // BUG <- should be called conditionally below.
Am I right, or is this the intended behavior? I am going to investigate it on my fork and will report back.
void showCancelConfirmationDialog() {
showDialog<dynamic>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text(widget.task.isConsentTask
? RPLocalizations.of(context)?.translate('cancel_confirmation') ??
"Cancel?"
: RPLocalizations.of(context)
?.translate('discard_confirmation') ??
"Discard results and quit?"),
actions: <Widget>[
ButtonTheme(
minWidth: 70,
child: TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
(CupertinoTheme.of(context).primaryColor ==
CupertinoColors.activeBlue)
? Theme.of(context).primaryColor
: CupertinoTheme.of(context).primaryColor),
),
child: Text(
RPLocalizations.of(context)?.translate('NO') ?? "NO",
style: const TextStyle(color: Colors.white),
),
onPressed: () =>
Navigator.of(context).pop(), // Dismissing the pop-up
),
),
OutlinedButton(
child: Text(
RPLocalizations.of(context)?.translate('YES') ?? "YES",
style: TextStyle(
color: ((CupertinoTheme.of(context).primaryColor ==
CupertinoColors.activeBlue)
? Theme.of(context).primaryColor
: CupertinoTheme.of(context).primaryColor)),
),
onPressed: () {
// Calling the onCancel method with which the developer can for
// e.g. save the result on the device.
// Only call it if it's not null
widget.onCancel?.call(_taskResult);
// Popup dismiss
Navigator.of(context).pop();
// Exit the Ordered Task
Navigator.of(context).pop(); // BUG <- should be called conditionally
},
)
],
);
},
);
}Metadata
Metadata
Assignees
Labels
No labels