Repository navigation
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.16Found to occur in 3.16Found to occur in 3.16found in release: 3.17Found to occur in 3.17Found to occur in 3.17frameworkflutter/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 onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: 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 team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Created nested MenuAnchors
- Select a MenuItem from the child MenuAnchor
- All MenuAnchors are closed, and error is thrown, and the onSelected method of the MenuItem is not called
Expected results
- The onSelected method of the selected MenuItem should be called
- No error should be thrown
- Only the Menu that contains the MenuItem should be closed (or this behaviour should be configurable)
Actual results
- All MenuAnchors are closed
- an error is thrown: 'A TextEditingController was used after being disposed.'
- the onSelected method of the MenuItem is not called
Code sample
Code sample
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: MenuAnchor(
menuChildren: [
ParentMenuModal(),
],
builder: (context, controller, widget) {
return IconButton(
icon: const Icon(Icons.smartphone_rounded),
onPressed: () {
controller.open();
},
);
},
),
)
);
}
}
class ParentMenuModal extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DropdownMenu(
label: const Text('Menu'),
initialSelection: "1",
dropdownMenuEntries: ["1", "2", "3"]
.map(
(it) =>
DropdownMenuEntry(
value: it,
label: it,
),
)
.toList(),
onSelected: (selection) {
// this is never called
print("selected: $selection");
},
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
A TextEditingController was used after being disposed.
Once you have called dispose() on a TextEditingController, it can no longer be used.
When the exception was thrown, this was the stack
════════════════════════════════════════════════════════════════════════════════════════════════════Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.16.1, on macOS 14.1 23B74 darwin-arm64, locale en-NZ)
• Flutter version 3.16.1 on channel stable at /Users/user/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7f20e5d18c (2 days ago), 2023-11-27 09:47:30 -0800
• Engine revision 22b600f240
• Dart version 3.2.1
• DevTools version 2.28.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/user/dev/android-sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/user/dev/android-sdk
• Java binary at: /Users/user/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode-15.0.1.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.14.2
[✓] Chrome - develop for the web
• CHROME_EXECUTABLE = /Users/user/google-chrome-unsafe.sh
[✓] Android Studio (version 2022.3)
• Android Studio at /Users/user/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
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
• IntelliJ at /Users/user/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin version 76.3.4
• Dart plugin version 232.10248
[✓] IntelliJ IDEA Ultimate Edition (version EAP IU-233.11799.67)
• IntelliJ at /Users/user/Applications/IntelliJ IDEA Ultimate 2023.3 Beta.app
• 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
[✓] VS Code (version 1.84.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.76.0
[✓] Connected device (3 available)
[✓] Network resources
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.16Found to occur in 3.16Found to occur in 3.16found in release: 3.17Found to occur in 3.17Found to occur in 3.17frameworkflutter/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 onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesr: 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 team
Activity
danagbemava-nc commentedon Nov 30, 2023
Reproducible using the code sample provided above.
I could reproduce this on stable 3.16.1 and master but when I tested on 3.13.9, it worked as expected.
flutter doctor -v
Fix `DropdownMenu` throwing `TextEditingController` disposed error on…
github-actions commentedon Dec 19, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.Fix `DropdownMenu` throwing `TextEditingController` disposed error on…