mirror of
https://github.com/flutter/flutter
synced 2024-07-16 10:29:14 +00:00
Fixed -> DropdownMenu throws exception when it is in any scrollable l… (#140566)
Fixed -> DropdownMenu throws exception when it is in any scrollable list view and scrolls quickly #139871
This commit is contained in:
parent
487d42f9ee
commit
874804e511
|
@ -493,6 +493,9 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
|
|||
|
||||
void refreshLeadingPadding() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
leadingPadding = getWidth(_leadingKey);
|
||||
});
|
||||
|
|
|
@ -1910,6 +1910,34 @@ void main() {
|
|||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/139871.
|
||||
testWidgets('setState is not called through addPostFrameCallback after DropdownMenu is unmounted', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ListView.builder(
|
||||
itemCount: 500,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index == 250) {
|
||||
return DropdownMenu<TestMenu>(
|
||||
dropdownMenuEntries: menuChildren,
|
||||
);
|
||||
} else {
|
||||
return Container(height: 50);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.fling(find.byType(ListView), const Offset(0, -20000), 200000.0);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('Menu shows scrollbar when height is limited', (WidgetTester tester) async {
|
||||
final List<DropdownMenuEntry<TestMenu>> menuItems = <DropdownMenuEntry<TestMenu>>[
|
||||
DropdownMenuEntry<TestMenu>(
|
||||
|
|
Loading…
Reference in a new issue