Skip to content

Flutter PlatformPlugin on Android's "popSystemNavigator" does not handle the FlutterFragment case in Add To App scenario #69879

@wugeo0824

Description

@wugeo0824

Steps to Reproduce

  1. Add Flutter to existing app
  2. Use FlutterFragment inside existing feature flow, where there are Android Fragments and FlutterFragment added into the same hosting Activity
  3. When user is on FlutterFragment, and fragment back stack looks like "FlutterFragment -> Android Fragment A -> Android Fragment B"
  4. User is on initialRoute on Flutter feature
  5. User presses back button

Expected results:

When user presses back button, the top FlutterFragment should be popped, and Android Fragment A should be visible

Actual results:

When user presses back button, the entire Activity was closed.

After some digging, the issue might be caused by Android side's Flutter PlatformPlugin implementation. Inside "io.flutter.plugin.platform.PlatformPlugin", it implements the popSystemNavigator callback as

  private void popSystemNavigator() {
    activity.finish();
  }

It will instruct the hosting activity to finish itself, regardless of how many fragments are there in the back stack.

Logs
➜ flutter doctor -v
[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.7 19H2, locale en-SG)
    • Flutter version 1.20.2 at /Users/xijun.li/Workspace/flutter
    • Framework revision bbfbf1770c (3 months ago), 2020-08-13 08:33:09 -0700
    • Engine revision 9d5b21729f
    • Dart version 2.9.1


[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/xijun.li/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/xijun.li/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C505
    • CocoaPods version 1.9.3

[!] Android Studio
    • Android Studio at /Applications/Android Studio 4.2 Preview.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Community Edition (version 2020.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 46.0.3
    • Dart plugin version 201.7846.93

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

[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: existing-appsIntegration with existing apps via the add-to-app flowfound in release: 1.22Found to occur in 1.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions