Skip to content

Scaffold's Current state isDrawerOpen parameter returns false in PopScope in flutter 3.22.0 but returns true in 3.19.0 #148896

Closed
@aakash-pamnani

Description

@aakash-pamnani

Steps to reproduce

  1. Run the below code on Flutter 3.22.0.
  2. Press the pop button in drawer, the homepage will be popped.
  3. Downgrade flutter to 3.19.0 run flutter downgrade v.3.19.0 and flutter clean
  4. Repeat same steps.
  5. Now the drawer will be closed but app will not pop.

Expected results

_key.currentState?.isDrawerOpen should return true when drawer is open and pop button clicked in version 3.22.0.

Actual results

_key.currentState?.isDrawerOpen is returning false when drawer is open and pop button clicked in version 3.22.0.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter App!!',
      home: const MyHomePage(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  GlobalKey<ScaffoldState> _key = new GlobalKey<ScaffoldState>();
  @override
  Widget build(BuildContext context) {
    return PopScope(
      canPop: false,
      onPopInvoked: (value) async {
        if (_key.currentState?.isDrawerOpen ?? false) {
          _key.currentState?.closeDrawer();
        } else {
          //show exit dialog
        }
      },
      child: Scaffold(
        key: _key,
        appBar: AppBar(
          title: Text("Flutter App"),
        ),
        drawer: Drawer(
          child: Center(
            child: ElevatedButton(
              onPressed: () {
                Navigator.of(context).pop();
              },
              child: Text("pop"),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Logs

Logs

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3593], locale en-IN)
    • Flutter version 3.19.6 on channel stable at H:\flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (5 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\no-admin\AppData\Local\Android\sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: H:\All Apps\android studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.7.34202.233
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.3)
    • Android Studio at H:\All Apps\android studio
    • 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-b2043.56-10027231)

[√] IntelliJ IDEA Community Edition (version 2023.2)
    • IntelliJ at H:\All Apps\idea community\IntelliJ IDEA Community Edition 2022.3.3
    • 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

[√] Connected device (4 available)
    • POCOPHONE F1 (mobile) • 73237c6e • android-arm64  • Android 14 (API 34)
    • Windows (desktop)     • windows  • windows-x64    • Microsoft Windows [Version 10.0.22631.3593]    
    • Chrome (web)          • chrome   • web-javascript • Google Chrome 124.0.6367.208
    • Edge (web)            • edge     • web-javascript • Microsoft Edge 125.0.2535.51

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.22Found to occur in 3.22found in release: 3.23Found to occur in 3.23has reproducible stepsThe issue has been confirmed reproducible and is ready to work onpackageflutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions