Skip to content

[go_router] PopScope not working on Android #138525

@minhnguyenandpad

Description

@minhnguyenandpad

Is there an existing issue for this?

Steps to reproduce

I have update to Flutter stable 3.16.0 and Dart 3.2.0
And migrate from WillPopScope to PopScope
Refer to: https://docs.flutter.dev/release/breaking-changes/android-predictive-back

Expected results

The _doSomethingWhenPressPhysicButton should be called when user press the physic back button on android.

Actual results

Nothing happen when I press the physic button.

Code sample

Code sample

Before:

WillPopScope(
  onWillPop: () async {
    _doSomethingWhenPressPhysicButton(); /// This is working
    return true;
  },
  child: ...
),

After:

PopScope(
  canPop: true,
  onPopInvoked (bool didPop) {
    _doSomethingWhenPressPhysicButton(); /// Nothing happen
  },
  child: ...
),

Screenshots or Video

Screenshots / Video demonstration

Logs

Logs
I/ViewRootImpl@e6d6173[MainActivity](31551): ViewPostIme pointer 0
I/ViewRootImpl@e6d6173[MainActivity](31551): ViewPostIme pointer 1

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.16.0, on macOS 12.6.1 21G217 darwin-arm64, locale en-JP)
    • Flutter version 3.16.0 on channel stable at /Users/minh.nguyen/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision db7ef5bf9f (10 hours 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 32.1.0-rc1)
    • Android SDK at /Users/minh.nguyen/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • ANDROID_HOME = /Users/minh.nguyen/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 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.13.0

[✓] 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)

[✓] VS Code (version 1.66.2)
    • VS Code at /Users/minh.nguyen/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (4 available)
    • SM G991B (mobile) • R5CR41JCJCD                          • android-arm64  • Android 13 (API 33)
    • macOS (desktop)   • macos                                • darwin-arm64   • macOS 12.6.1 21G217 darwin-arm64
    • Chrome (web)      • chrome                               • web-javascript • Google Chrome 119.0.6045.123

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: duplicateIssue is closed as a duplicate of an existing issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions