-
Notifications
You must be signed in to change notification settings - Fork 27.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scaffold's Current state isDrawerOpen
parameter returns false in PopScope in flutter 3.22.0 but returns true in 3.19.0
#148896
Comments
isDrawerOpen
parameter returns false in PopScope in flutter 3.22.0 but works in 3.19.0isDrawerOpen
parameter returns false in PopScope in flutter 3.22.0 but returns true in 3.19.0
Hi @aakash-pamnani The only factor I think about is the device you are checking on. Could you try another device to see if the result changes? |
The issue is when using with go_router. When i add router in my app it returns false. Codeimport 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Flutter App!!',
routerConfig: GoRouter(
initialLocation: "/",
routes: [
GoRoute(
path: "/",
builder: (context, state) => const MyHomePage(),
),
],
),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final GlobalKey<ScaffoldState> _key = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
onPopInvoked: (value) async {
print("isDrawerOpen: ${_key.currentState?.isDrawerOpen}");
if (_key.currentState?.isDrawerOpen ?? false) {
_key.currentState?.closeDrawer();
} else {
//show exit dialog
}
},
child: Scaffold(
key: _key,
appBar: AppBar(
title: const Text("Flutter App"),
),
drawer: SizedBox.expand(
child: Drawer(
child: Center(
child: ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text("pop"),
),
),
),
),
),
);
}
}
|
I checked this again on both Android 11 and Android 14 devices on Flutter 3.19.6 but Labelling this issue as a flutter doctor -v (stable and master)[✓] Flutter (Channel stable, 3.22.1, on macOS 14.1 23B74 darwin-x64, locale en-VN)
• Flutter version 3.22.1 on channel stable at /Users/huynq/Documents/GitHub/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a14f74ff3a (11 hours ago), 2024-05-22 11:08:21 -0500
• Engine revision 55eae6864b
• Dart version 3.4.1
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/huynq/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/huynq/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode15.3.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.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
• android-studio-dir = /Applications/Android Studio.app/
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
[✓] VS Code (version 1.89.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 14.1 23B74 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 125.0.6422.76
[✓] Network resources
• All expected network resources are available.
• No issues found! [!] Flutter (Channel master, 3.23.0-8.0.pre.8, on macOS 14.1 23B74 darwin-x64, locale en-VN)
• Flutter version 3.23.0-8.0.pre.8 on channel master at /Users/huynq/Documents/GitHub/flutter_master
! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 8fd8e66de4 (3 hours ago), 2024-05-26 21:49:30 -0400
• Engine revision 469193ef0e
• Dart version 3.5.0 (build 3.5.0-191.0.dev)
• DevTools version 2.36.0-dev.10
• 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/huynq/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/huynq/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode15.3.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.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
• android-studio-dir = /Applications/Android Studio.app/
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
[✓] VS Code (version 1.89.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0
[✓] Connected device (3 available)
• Pixel 7 (mobile) • 2B171FDH20084L • android-arm64 • Android 14 (API 34)
• macOS (desktop) • macos • darwin-x64 • macOS 14.1 23B74 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 125.0.6422.77
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category. |
This is not related to go_router, cc @justinmc looks like we may have missed something in scaffold |
@aakash-pamnani I check this on the latest stable 3.24.1, |
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. |
Steps to reproduce
3.19.0
runflutter downgrade v.3.19.0
andflutter clean
Expected results
_key.currentState?.isDrawerOpen
should returntrue
when drawer is open and pop button clicked in version 3.22.0.Actual results
_key.currentState?.isDrawerOpen
is returningfalse
when drawer is open and pop button clicked in version 3.22.0.Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
Logs
Logs
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: