Skip to content

WillPopScope onWillPop doesn't get called upon tapping a back key on Android in the latest master. #62734

@njovy

Description

@njovy

Steps to Reproduce

  1. Run flutter create bug.
  2. Update the files as follows:
import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(title: 'WillPopScope', home: MyApp()));
}

class MyApp extends StatefulWidget {
  // This widget is the root of your application.
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        return showDialog<bool>(
            context: context,
            builder: (context) => AlertDialog(
                  title: Text("Quit?"),
                  actions: [
                    FlatButton(
                      onPressed: () => Navigator.of(context).pop(true),
                      child: Text("OK"),
                    )
                  ],
                ));
      },
      child: Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: Icon(Icons.close),
            onPressed: () => Navigator.of(context).maybePop(),
          ),
        ),
      ),
    );
  }
}

Expected results: onWillPop should be called upon tapping a back key.

Actual results: onWillPop never gets called upon tapping a back key.
I had to use the latest master because of this issue #60926. However, I found this issue in the latest master so I couldn't patch a new version at the moment. Please fix this ASAP.

[✓] Flutter (Channel master, 1.21.0-6.0.pre.141, on Mac OS X 10.15.3 19D76, locale en-KR)
    • Flutter version 1.21.0-6.0.pre.141 at /Users/captainpark/Library/Flutter/sdk
    • Framework revision c748f1a7aa (22 hours ago), 2020-07-31 17:45:18 -0700
    • Engine revision 280bbfc763
    • Dart version 2.10.0 (build 2.10.0-2.0.dev bd528bfbd6)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/captainpark/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /Users/captainpark/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_202-release-1483-b49-5587405)
    • All Android licenses accepted.

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

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.1.4)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 48.0.3-dev.3
    • Dart plugin version 201.8538.45

[✓] Connected device (2 available)
    • SM G965N (mobile) • 21bd4fb43b037ece • android-arm64 • Android 9 (API 28)
    • SM G981N (mobile) • R3CN40AGS3T      • android-arm64 • Android 10 (API 29)
• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions