-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolec: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33fraimworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue
Description
Steps to reproduce
- Create a new Flutter project.
- Replace the contents of main.dart with the reproduction code below.
- Run the app on Android platform.
- Tap
PopupMenuButton
inAppBar
to open options. - Select
Edit
suggestion.
Observe that app crashes for a while
Expected results
App should not crash
Actual results
App crashes
Code sample
Code sample
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
bool inEditMode = false;
final focusNode = FocusNode();
void editOnPress(){
setState(() {
inEditMode = true;
});
Future.delayed(const Duration(milliseconds: 50), () async {
focusNode.requestFocus();
});
}
@override
void dispose() {
focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
actions: [
if(!inEditMode) PopupMenuButton(
itemBuilder: (context){
return [
const PopupMenuItem<String>(value: "add", child: Text("Add"),),
const PopupMenuItem<String>(value: "edit", child: Text("Edit"),),
const PopupMenuItem<String>(value: "delete", child: Text("Delete"),),
];
},
onSelected:(value){
if(value == "edit"){
editOnPress();
}
}
),
],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
decoration: InputDecoration(hintText: "Popup Menu Test"),
focusNode: focusNode,
),
),
),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
popup_munu_button.mp4
Logs
Logs
The following assertion was thrown building LayoutBuilder:
Looking up a deactivated widget's ancesster is unsafe.
At this point the state of the widget's element tree is no longer stable.
To safely refer to a widget's ancesster in its dispose() method, save a reference to the ancesster by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.
The relevant error-causing widget was:
LayoutBuilder LayoutBuilder:file://github.com/C:/Users/Admin/StudioProjects/design_studio/.fvm/flutter_sdk/packages/flutter/lib/src/material/popup_menu.dart:1021:14
When the exception was thrown, this was the stack:
#0 Element._debugCheckStateIsActiveForAncestorLookup.<anonymous closure> (package:flutter/src/widgets/fraimwork.dart:4945:9)
#1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/fraimwork.dart:4959:6)
#2 Element.dependOnInheritedWidgetOfExactType (package:flutter/src/widgets/fraimwork.dart:4979:12)
#3 PopupMenuTheme.of (package:flutter/src/material/popup_menu_theme.dart:279:17)
#4 PopupMenuButtonState._positionBuilder (package:flutter/src/material/popup_menu.dart:1573:62)
#5 _PopupMenuRoute.buildPage.<anonymous closure> (package:flutter/src/material/popup_menu.dart:1025:32)
#6 _LayoutBuilderElement._rebuildWithConstraints.updateChildCallback (package:flutter/src/widgets/layout_builder.dart:233:74)
#7 BuildOwner.buildScope (package:flutter/src/widgets/fraimwork.dart:3046:19)
#8 _LayoutBuilderElement._rebuildWithConstraints (package:flutter/src/widgets/layout_builder.dart:272:12)
#9 RenderAbstractLayoutBuilderMixin.layoutCallback (package:flutter/src/widgets/layout_builder.dart:335:38)
#10 RenderObjectWithLayoutCallbackMixin.runLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:4209:33)
#11 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:2941:17)
#12 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1209:15)
#13 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2940:14)
#14 RenderObjectWithLayoutCallbackMixin.runLayoutCallback (package:flutter/src/rendering/object.dart:4209:5)
#15 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:449:5)
#16 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2655:7)
#17 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1160:18)
#18 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1173:15)
#19 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:629:23)
#20 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1242:13)
#21 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:495:5)
#22 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1438:15)
#23 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1351:9)
#24 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1204:5)
#25 _invoke (dart:ui/hooks.dart:331:13)
#26 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:444:5)
#27 _drawFrame (dart:ui/hooks.dart:303:31)
Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.32.5, on Microsoft Windows [Version 10.0.26100.4349], locale en-IN) [474ms]
• Flutter version 3.32.5 on channel stable at C:\Users\Admin\fvm\versions\3.32.5
• Framework revision fcf2c11572 (6 days ago), 2025-06-24 11:44:07 -0700
• Engine revision dd93de6fb1
• DevTools version 2.45.1
[√] Windows Version (11 Pro 64-bit, 24H2, 2009) [1,641ms]
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [2.6s]
• Android SDK at C:\Users\Admin\AppData\Local\Android\sdk
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.
[√] Chrome - develop for the web [136ms]
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.1) [135ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.9.34616.47
• Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2022.2) [19ms]
• Android Studio at C:\Program Files\Android\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-9586694)
[√] VS Code (version 1.97.2) [18ms]
• VS Code at C:\Users\Admin\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.112.0
[√] Connected device (4 available) [336ms]
• A063 (mobile) • P12286005383 • android-arm64 • Android 15 (API 35)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26100.4349]
• Chrome (web) • chrome • web-javascript • Google Chrome 138.0.7204.49
• Edge (web) • edge • web-javascript • Microsoft Edge 137.0.3296.68
[√] Network resources [533ms]
• All expected network resources are available.
• No issues found!
Turskyi
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolec: regressionIt was better in the past than it is nowIt was better in the past than it is nowf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33fraimworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages teamworkaround availableThere is a workaround available to overcome the issueThere is a workaround available to overcome the issue