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
8cbc8492
Unverified
Commit
8cbc8492
authored
Oct 28, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix dropdown crash (#69211)
parent
e71655b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
1 deletion
+51
-1
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+3
-1
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+48
-0
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
8cbc8492
...
...
@@ -456,7 +456,9 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> {
}
void
_dismiss
()
{
navigator
?.
removeRoute
(
this
);
if
(
isActive
)
{
navigator
?.
removeRoute
(
this
);
}
}
double
getItemOffset
(
int
index
)
{
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
8cbc8492
...
...
@@ -2615,4 +2615,52 @@ void main() {
expect
(
value
,
equals
(
'two'
));
expect
(
menuItemTapCounters
,
<
int
>[
0
,
2
,
1
,
0
]);
});
testWidgets
(
'does not crash when option is selected without waiting for opening animation to complete'
,
(
WidgetTester
tester
)
async
{
// Regression test for b/171846624.
final
List
<
String
>
options
=
<
String
>[
'first'
,
'second'
,
'third'
];
String
?
value
=
options
.
first
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
=>
DropdownButton
<
String
>(
value:
value
,
items:
options
.
map
((
String
s
)
=>
DropdownMenuItem
<
String
>(
value:
s
,
child:
Text
(
s
),
)).
toList
(),
onChanged:
(
String
?
v
)
{
setState
(()
{
value
=
v
;
});
},
),
),
),
),
);
expect
(
find
.
text
(
'first'
).
hitTestable
(),
findsOneWidget
);
expect
(
find
.
text
(
'second'
).
hitTestable
(),
findsNothing
);
expect
(
find
.
text
(
'third'
).
hitTestable
(),
findsNothing
);
// Open dropdown.
await
tester
.
tap
(
find
.
text
(
'first'
).
hitTestable
());
await
tester
.
pump
();
expect
(
find
.
text
(
'third'
).
hitTestable
(),
findsOneWidget
);
expect
(
find
.
text
(
'first'
).
hitTestable
(),
findsOneWidget
);
expect
(
find
.
text
(
'second'
).
hitTestable
(),
findsOneWidget
);
// Deliberately not waiting for opening animation to complete!
// Select an option in dropdown.
await
tester
.
tap
(
find
.
text
(
'third'
).
hitTestable
());
await
tester
.
pump
();
expect
(
find
.
text
(
'third'
).
hitTestable
(),
findsOneWidget
);
expect
(
find
.
text
(
'first'
).
hitTestable
(),
findsNothing
);
expect
(
find
.
text
(
'second'
).
hitTestable
(),
findsNothing
);
});
}
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