Skip to content

[Sheet] PopScope - fix onPopInvoked usage in preventPop #452

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Michae1Weiss
Copy link

Problem

The onPopInvoked method in Route is deprecated and no longer triggers pop handling, which prevents onPopInvokedWithResult in PopScope from being called. As a result, PopScope does not properly intercept back navigation when using SheetRoute and derived classes.

Before

Screencast.from.2025-02-01.14-15-22.webm

After

Screencast.from.2025-02-01.14-16-01.webm

Solution

Updated preventPop to call onPopInvokedWithResult instead of the deprecated onPopInvoked.

Changes

  • Replaced route.onPopInvoked(false) with route.onPopInvokedWithResult(false, null) in preventPop.

Evidence

  • Added a PopScope example to the project for future testing.

🚀

Copy link
Collaborator

@orestesgaolin orestesgaolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orestesgaolin
Copy link
Collaborator

Thanks @Michae1Weiss for the contribution. Wondering if you have any thoughts on onPopPage being deprecated as well?

@Michae1Weiss
Copy link
Author

Good point! I should test that as well. Thanks for the hint, @orestesgaolin . I'll take a closer look at it tomorrow.

@huynhmytuandev
Copy link

Is there any update on this?

@Michae1Weiss
Copy link
Author

Michae1Weiss commented Mar 25, 2025

Is there any update on this?

Thanks for the reminder @huynhmytuandev ! I actually have a few days off this week, so I’ll finally do a deep dive into onPopPage and Co (as @orestesgaolin mentioned) and test some edge cases.
To make PopScope work properly, I’m currently using this in my pubspec.yaml:

  # The official package doesn’t yet include my pull request (`[Sheet] PopScope - ... #452`),
  # so until it's merged, I’m using my own fork to get the fix.
  # Once it's merged upstream, we can switch back to the official package.
  sheet:
    git:
      url: https://github.com/Michae1Weiss/modal_bottom_sheet.git 
      ref: main
      path: sheet/

If you don’t hear from me this week, feel free to poke me again — I’m a professional procrastinator

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.

3 participants