Skip to content

PopScope does not invoke onPopInvoked for iOS back gesture when canPop set to false #138624

Open

Description

@btrautmann

Is there an existing issue for this?

Steps to reproduce

Original comment was made at #138525 (comment) but I'm pasting here:

[...] our team was investigating PopScope and found some interesting behavior that can be reproduced using this repo. I don't believe this component is behaving as described in the docs.

Using Navigator 1.0 APIs on iOS 17:

  1. When canPop is set to true, user can go back via app bar or back button and onPopInvoked is invoked with didPop set to true in both cases.
  2. When canPop is set to false, user cannot go back via app bar or back button, but onPopInvoked is only invoked with didPop set to false when pressing app bar back button. It is not invoked at all for the back gesture, which is unexpected per the docs (which read The [onPopInvoked] parameter reports when system back gestures occur, regardless of whether or not they were successful).

Using Navigator 1.0 APIs on Android 14:

  1. When canPop is set to true, user can go back via app bar or back button and onPopInvoked is invoked with didPop set to true in both cases.
  2. When canPop is set to false, user cannot go back via app bar or back button, and onPopInvoked is invoked in both cases with didPop set to false

Summary Table:

NOTE: For clarity, please note that for each column with onPopInvoked in the title, the true or false in the rows associated with that column indicate whether or not the onPopInvoked callback was invoked. This column is NOT intended to indicate anything about the didPop value, which is always (AFAIK) correct.

Platform Nav API canPop onPopInvoked(appBar) onPopInvoked (back swipe) onPopInvoked (Physical button) Expected behavior?
iOS 1.0 true true true --- true
iOS 1.0 false true false --- false
Android 1.0 true true true true true
Android 1.0 false true true true true

Expected results

The component should behave as described in the docs.

Actual results

See the table in the Steps to reproduce section.

Code sample

Code can be found in this repo.

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.16.0, on macOS 13.6.1 22G313 darwin-arm64, locale en-US)
    • Flutter version 3.16.0 on channel stable at /Users/brandontrautmann/fvm/versions/3.16.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db7ef5bf9f (2 days ago), 2023-11-15 11:25:44 -0800
    • Engine revision 74d16627b9
    • Dart version 3.2.0
    • DevTools version 2.28.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/brandontrautmann/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • ANDROID_SDK_ROOT = /Users/brandontrautmann/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode_14.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Community Edition (version 2023.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.84.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.76.0

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 13 (API 33) (emulator)
    • iPhone 13 mini (mobile)     • 0492C672-A151-402C-AAA0-0B694038CF37 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 13.6.1 22G313 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 119.0.6045.159

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Activity

  1. dam-ease commented on Nov 20, 2023

    @dam-ease

    Thanks for filing this and for the detailed explanation.
    Testing with Nav API 1.0, I see the issue occurs only on the second row, where canPop is set to false on iOS. Others seem to work as expected both on Android and iOS (kindly provide more information on this if my understanding of this is incorrect)

    Platform Nav API canPop onPopInvoked(appBar) onPopInvoked (back swipe) onPopInvoked (Physical button) Expected behavior?
    iOS 1.0 false true false --- false

    For the second row as I referenced above, running the reproduction sample and testing with canPop set to false, I can't seem to reproduce onPopInvoked(appBar) being true (logs below).

    flutter: onPopInvoked didPop? false
    
    Screen record

    Screen.Recording.2023-11-20.at.13.39.22.mov

    Can you confirm this on your end again as well?

    I'd also suggest separating the issue with Nav API 1.0 from that reproduced with go_router so it's easier to track but if on confirmation of the one issue with Nav API 1.0, if it doesn't persist, I guess we could retain this and triage the issues when using go_router

    flutter doctor -v

    [!] Flutter (Channel stable, 3.16.0, on macOS 14.0 23A344 darwin-arm64, locale
        en-NG)
        • Flutter version 3.16.0 on channel stable at
          /Users/damilolaalimi/sdks/flutter
        ! Warning: `dart` on your path resolves to
          /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/damilolaalimi/sdks/flutter.
          Consider adding /Users/damilolaalimi/sdks/flutter/bin to the front of your
          path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision db7ef5bf9f (5 days ago), 2023-11-15 11:25:44 -0800
        • Engine revision 74d16627b9
        • Dart version 3.2.0
        • DevTools version 2.28.2
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/damilolaalimi/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 15A507
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build
          17.0.6+0-17.0.6b802.4-9586694)
    
    [!] Android Studio (version unknown)
        • Android Studio at /Users/damilolaalimi/Downloads/Android Studio
          Preview.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build
          17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] VS Code (version 1.84.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] VS Code (version 1.83.1)
        • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] Connected device (5 available)
        • sdk gphone64 arm64 (mobile) • emulator-5554                        •
          android-arm64  • Android 14 (API 34) (emulator)
        • Damilola’s iPhone (mobile)  • 00008110-001964480AE1801E            • ios
          • iOS 17.1.1 21B91
        • iPhone 15 (mobile)          • F17D2919-6D61-4295-8408-1719692FE958 • ios
          • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
        • macOS (desktop)             • macos                                •
          darwin-arm64   • macOS 14.0 23A344 darwin-arm64
        • Chrome (web)                • chrome                               •
          web-javascript • Google Chrome 119.0.6045.159
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 2 categories.
    

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 20, 2023
  3. btrautmann commented on Nov 20, 2023

    @btrautmann
    Author

    For the second row as I referenced above, running the reproduction sample and testing with canPop set to false, I can't seem to reproduce onPopInvoked(appBar) being true (logs below).

    I'm sorry, this was a lack of clarity on my part. For each column that has onPopInvoked, the true or false indicates whether or not the callback was invoked, not what the didPop value actually was. As far as I recall, the didPop value was always correct whenever the callback was actually invoked, as it is in your screen recording!

    Edit: I've added a clarification above the Summary Table in the description to (hopefully) clear up the intent of those columns.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 20, 2023
  5. changed the title [-]PopScope does not behave as expected in several situations[/-] [+]PopScope does not invoked `onPopInvoked` for iOS back gesture when `canPop` set to false[/+] on Nov 20, 2023
  6. btrautmann commented on Nov 20, 2023

    @btrautmann
    Author

    As requested, I've opened #138737 which covers all GoRouter cases. I've narrowed the scope of this ticket as well as its description to capture the issue with Navigator 1.0 APIs.

  7. changed the title [-]PopScope does not invoked `onPopInvoked` for iOS back gesture when `canPop` set to false[/-] [+]PopScope does not invoke `onPopInvoked` for iOS back gesture when `canPop` set to false[/+] on Nov 20, 2023
  8. dam-ease commented on Nov 21, 2023

    @dam-ease

    For each column that has onPopInvoked, the true or false indicates whether or not the callback was invoked, not what the didPop value actually was.

    Thanks for explaining further. I can reproduce this on the latest master and stable, channels as also shown in the video at #138624 (comment).

    stable, master flutter doctor -v

    [!] Flutter (Channel stable, 3.16.0, on macOS 14.0 23A344 darwin-arm64, locale
        en-NG)
        • Flutter version 3.16.0 on channel stable at
          /Users/damilolaalimi/sdks/flutter
        ! Warning: `dart` on your path resolves to
          /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/damilolaalimi/sdks/flutter.
          Consider adding /Users/damilolaalimi/sdks/flutter/bin to the front of your
          path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision db7ef5bf9f (5 days ago), 2023-11-15 11:25:44 -0800
        • Engine revision 74d16627b9
        • Dart version 3.2.0
        • DevTools version 2.28.2
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/damilolaalimi/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 15A507
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build
          17.0.6+0-17.0.6b802.4-9586694)
    
    [!] Android Studio (version unknown)
        • Android Studio at /Users/damilolaalimi/Downloads/Android Studio
          Preview.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build
          17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] VS Code (version 1.84.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] VS Code (version 1.83.1)
        • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] Connected device (5 available)
        • sdk gphone64 arm64 (mobile) • emulator-5554                        •
          android-arm64  • Android 14 (API 34) (emulator)
        • Damilola’s iPhone (mobile)  • 00008110-001964480AE1801E            • ios
          • iOS 17.1.1 21B91
        • iPhone 15 (mobile)          • F17D2919-6D61-4295-8408-1719692FE958 • ios
          • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
        • macOS (desktop)             • macos                                •
          darwin-arm64   • macOS 14.0 23A344 darwin-arm64
        • Chrome (web)                • chrome                               •
          web-javascript • Google Chrome 119.0.6045.159
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 2 categories.
    
    [!] Flutter (Channel master, 3.17.0-12.0.pre.39, on macOS 14.0 23A344 darwin-arm64, locale en-NG)
        • Flutter version 3.17.0-12.0.pre.39 on channel master at /Users/damilolaalimi/fvm/versions/master
        ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/damilolaalimi/fvm/versions/master. Consider adding /Users/damilolaalimi/fvm/versions/master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision b6ef78e955 (4 hours ago), 2023-11-20 23:37:25 -0500
        • Engine revision 70b1c73412
        • Dart version 3.3.0 (build 3.3.0-152.0.dev)
        • DevTools version 2.30.0-dev.4
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/damilolaalimi/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 15A507
        • CocoaPods version 1.12.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    
    [!] Android Studio (version unknown)
        • Android Studio at /Users/damilolaalimi/Downloads/Android Studio Preview.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] VS Code (version 1.84.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] VS Code (version 1.83.1)
        • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
        • Flutter extension version 3.50.0
    
    [✓] Connected device (5 available)
        • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 14 (API 34) (emulator)
        • Damilola’s iPhone (mobile)  • 00008110-001964480AE1801E            • ios            • iOS 17.1.1 21B91
        • iPhone 15 (mobile)          • F17D2919-6D61-4295-8408-1719692FE958 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
        • macOS (desktop)             • macos                                • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
        • Chrome (web)                • chrome                               • web-javascript • Google Chrome 119.0.6045.159
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 2 categories.
    

  9. added
    platform-iosiOS applications specifically
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Nov 21, 2023
  10. 67 remaining items

  11. flutter-triage-bot commented on Apr 1, 2025

    @flutter-triage-bot

    This issue is assigned to @chunhtai but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  12. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Apr 1, 2025
  13. flutter-triage-bot commented on Jun 17, 2025

    @flutter-triage-bot

    This issue was assigned to @chunhtai but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.

  14. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Jun 17, 2025
  15. justinmc commented on Jun 17, 2025

    @justinmc
    Contributor

    @chunhtai Is this still a P1? Do you plan to return to it?

  16. flutter-triage-bot commented on Oct 22, 2025

    @flutter-triage-bot

    This issue is marked P1 but has had no recent status updates.

    The P1 label indicates high-priority issues that are at the top of the work list. This is the highest priority level a bug can have if it isn't affecting a top-tier customer or breaking the build. Bugs marked P1 are generally actively being worked on unless the assignee is dealing with a P0 bug (or another P1 bug). Issues at this level should be resolved in a matter of months and should have monthly updates on GitHub.

    Please consider where this bug really falls in our current priorities, and label it or assign it accordingly. This allows people to have a clearer picture of what work is actually planned. Thanks!

  17. added
    P2Important issues not at the top of the work list
    and removed
    P1High-priority issues at the top of the work list
    on Oct 29, 2025
  18. cristovaoFariasSmart commented on Oct 31, 2025

    @cristovaoFariasSmart

    this must be a P1, a lot of companies are doing workarounds to make swipeback work properly becasue of that

  19. caseycrogers commented on Nov 3, 2025

    @caseycrogers
    Contributor

    this must be a P1, a lot of companies are doing workarounds to make swipeback work properly becasue of that

    Not a Google employee, but refer to my earlier comment, there is no way to support onPopInvoked for the iOS back gesture. The request is internally inconsistent. onPopInvoked should document this limitation, but it is working as intended. Google will not be able to solve this for you as the request is inherently not possible (at least not without coherent UX).
    #138624 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.found in release: 3.16Found to occur in 3.16found in release: 3.17Found to occur in 3.17frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions