Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
73f7945b
Unverified
Commit
73f7945b
authored
Apr 19, 2023
by
xubaolin
Committed by
GitHub
Apr 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix DropdownMenu crash when resize window during menu showing (#124855)
parent
ea34f7df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
3 deletions
+67
-3
dropdown_menu.dart
packages/flutter/lib/src/material/dropdown_menu.dart
+0
-1
menu_anchor.dart
packages/flutter/lib/src/material/menu_anchor.dart
+3
-2
dropdown_menu_test.dart
packages/flutter/test/material/dropdown_menu_test.dart
+64
-0
No files found.
packages/flutter/lib/src/material/dropdown_menu.dart
View file @
73f7945b
...
...
@@ -542,7 +542,6 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
controller:
_controller
,
menuChildren:
menu
,
crossAxisUnconstrained:
false
,
onClose:
()
{
setState
(()
{});
},
// To update the status of the IconButton
builder:
(
BuildContext
context
,
MenuController
controller
,
Widget
?
child
)
{
assert
(
_initialMenu
!=
null
);
final
Widget
trailingButton
=
Padding
(
...
...
packages/flutter/lib/src/material/menu_anchor.dart
View file @
73f7945b
...
...
@@ -342,7 +342,7 @@ class _MenuAnchorState extends State<MenuAnchor> {
// Needs to update the overlay entry on the next frame, since it's in the
// overlay.
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
_
)
{
_overlayEntry
!
.
markNeedsBuild
();
_overlayEntry
?
.
markNeedsBuild
();
});
}
}
...
...
@@ -556,8 +556,9 @@ class _MenuAnchorState extends State<MenuAnchor> {
// Notify that _childIsOpen changed state, but only if not
// currently disposing.
_parent
?.
_childChangedOpenState
();
widget
.
onClose
?.
call
();
setState
(()
{});
}
widget
.
onClose
?.
call
();
}
void
_closeChildren
({
bool
inDispose
=
false
})
{
...
...
packages/flutter/test/material/dropdown_menu_test.dart
View file @
73f7945b
...
...
@@ -405,6 +405,70 @@ void main() {
expect
(
menuMaterial
,
findsOneWidget
);
});
testWidgets
(
'Leading IconButton status test'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
themeData
=
ThemeData
(
useMaterial3:
true
);
await
tester
.
pumpWidget
(
buildTest
(
themeData
,
menuChildren
,
width:
100.0
,
menuHeight:
100.0
));
await
tester
.
pump
();
Finder
iconButton
=
find
.
widgetWithIcon
(
IconButton
,
Icons
.
arrow_drop_up
);
expect
(
iconButton
,
findsNothing
);
iconButton
=
find
.
widgetWithIcon
(
IconButton
,
Icons
.
arrow_drop_down
).
first
;
expect
(
iconButton
,
findsOneWidget
);
await
tester
.
tap
(
iconButton
);
await
tester
.
pump
();
iconButton
=
find
.
widgetWithIcon
(
IconButton
,
Icons
.
arrow_drop_up
).
first
;
expect
(
iconButton
,
findsOneWidget
);
iconButton
=
find
.
widgetWithIcon
(
IconButton
,
Icons
.
arrow_drop_down
);
expect
(
iconButton
,
findsNothing
);
// Tap outside
await
tester
.
tapAt
(
const
Offset
(
500.0
,
500.0
));
await
tester
.
pump
();
iconButton
=
find
.
widgetWithIcon
(
IconButton
,
Icons
.
arrow_drop_up
);
expect
(
iconButton
,
findsNothing
);
iconButton
=
find
.
widgetWithIcon
(
IconButton
,
Icons
.
arrow_drop_down
).
first
;
expect
(
iconButton
,
findsOneWidget
);
});
testWidgets
(
'Do not crash when resize window during menu opening'
,
(
WidgetTester
tester
)
async
{
addTearDown
(
tester
.
view
.
reset
);
final
ThemeData
themeData
=
ThemeData
();
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
themeData
,
home:
Scaffold
(
body:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
){
return
DropdownMenu
<
TestMenu
>(
width:
MediaQuery
.
of
(
context
).
size
.
width
,
dropdownMenuEntries:
menuChildren
,
);
},
),
),
));
final
Finder
iconButton
=
find
.
widgetWithIcon
(
IconButton
,
Icons
.
arrow_drop_down
).
first
;
expect
(
iconButton
,
findsOneWidget
);
await
tester
.
tap
(
iconButton
);
await
tester
.
pump
();
final
Finder
menuMaterial
=
find
.
ancestor
(
of:
find
.
widgetWithText
(
MenuItemButton
,
TestMenu
.
mainMenu0
.
label
),
matching:
find
.
byType
(
Material
),
).
last
;
expect
(
menuMaterial
,
findsOneWidget
);
// didChangeMetrics
tester
.
view
.
physicalSize
=
const
Size
(
700.0
,
700.0
);
await
tester
.
pump
();
// Go without throw.
});
testWidgets
(
'DropdownMenu can customize trailing icon button'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
themeData
=
ThemeData
();
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment