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

Fix: PopScope not working with modals in Flutter 3.24+ #237

Merged
merged 10 commits into from
Aug 31, 2024

Conversation

fujidaiti
Copy link
Owner

@fujidaiti fujidaiti commented Aug 31, 2024

Related issues (optional)

Fixes #233.

Description

This PR migrates from Route.onPopInvoked to Route.onPopInvokedWithResult to address the issue. Here's a detailed explanation of this change (quoted from the README):

This package previously used the Route.onPopInvoked method to invoke PopScope.onPopInvoked callbacks when users performed a swipe-to-dismiss gesture. However, these methods were deprecated in Flutter 3.24.0 as part of a breaking change related to the PopScope widget. The problem is that ModalRoute.onPopInvoked, which was an override of Route.onPopInvoked and where PopScope.onPopInvoked callbacks were actually invoked, was removed. As a result, the PopScope.onPopInvoked callback is no longer invoked in Flutter 3.24+. These changes led to issues such as #233.

The only possible solution was to replace Route.onPopInvoked with Route.onPopInvokedWithResult, which was introduced in Flutter 3.24.0. However, migrating to the new API would require increasing the lower bound of the SDK constraint to 3.24.0. For those using an SDK version lower than 3.24, this change would be a significant breaking change. Ultimately, we decided to publish different versions for different SDK constraints to maintain backward compatibility.

Summary (check all that apply)

  • Modified / added code
  • Modified / added tests
  • Modified / added examples
  • Modified / added others (pubspec.yaml, workflows, etc...)
  • Updated README
  • Contains breaking changes
    • Created / updated migration guide
  • Incremented version number
    • Updated CHANGELOG

@fujidaiti fujidaiti self-assigned this Aug 31, 2024
@fujidaiti fujidaiti changed the title Migrate to onPopInvokedWithResult Fix: PopScope not working with modals in Flutter 3.24+ Aug 31, 2024
@fujidaiti fujidaiti marked this pull request as ready for review August 31, 2024 21:44
@fujidaiti fujidaiti merged commit 87bd654 into v1.0.0-f324.x Aug 31, 2024
9 checks passed
@fujidaiti fujidaiti deleted the fix-popscope-issue branch August 31, 2024 21:45
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

Successfully merging this pull request may close these issues.

1 participant