Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

barrierDismissible not working properly #457

Open
Anilaydinaa opened this issue Oct 1, 2024 · 2 comments
Open

barrierDismissible not working properly #457

Anilaydinaa opened this issue Oct 1, 2024 · 2 comments

Comments

@Anilaydinaa
Copy link

Anilaydinaa commented Oct 1, 2024

I’ve encountered an issue with the barrierDismissible parameter in the UpgradeAlert widget not working as expected. The issue seems to stem from the onCanPop function in the upgrade_alert.dart file, which is always returning false, preventing the dialog from being dismissed.

Here’s the relevant part of the onCanPop function:

bool onCanPop() {
if (widget.upgrader.state.debugLogging) {
print('upgrader: onCanPop called');
}
if (widget.shouldPopScope != null) {
final should = widget.shouldPopScope!();
if (widget.upgrader.state.debugLogging) {
print('upgrader: shouldPopScope=$should');
}
return should;
}
return false;
}

Solution:

By making a small change to the onCanPop function, I was able to get barrierDismissible working properly. The key change is to return the widget.barrierDismissible value instead of always returning false:

bool onCanPop() {
if (widget.upgrader.state.debugLogging) {
print('upgrader: onCanPop called');
}
if (widget.shouldPopScope != null) {
final should = widget.shouldPopScope!();
if (widget.upgrader.state.debugLogging) {
print('upgrader: shouldPopScope=$should');
}
return should;
}
return widget.barrierDismissible;
}

With this modification, the barrierDismissible parameter now works as expected.

Is this a bug? Or did you do this intentionally? If so, why did you include the barrierDismissible parameter as an assignable value?

Good luck :)

@Anilaydinaa
Copy link
Author

Solution to the problem:

UpgradeAlert(
shouldPopScope: () => true,
barrierDismissible: true,
dialogStyle: UpgradeDialogStyle.cupertino,
upgrader: Upgrader(
durationUntilAlertAgain: const Duration(minutes: 10),
),
)

Result: When the shouldPopScope and barrierDismissible parameters are used together, it works.

I will not delete the topic so that others who face the same issue can benefit from it.

If this is a bug, I hope it gets resolved soon.

P.S.: This works without making any changes to the main file of the package (upgrade_alert.dart).

@tekinonur
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants