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
f69b8d33
Unverified
Commit
f69b8d33
authored
Mar 15, 2021
by
David Darrell
Committed by
GitHub
Mar 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DropdownItems with a null value should still display its child (#77666)
parent
8b144544
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
2 deletions
+50
-2
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+6
-1
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+44
-1
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
f69b8d33
...
...
@@ -1200,7 +1200,12 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
}
void
_updateSelectedIndex
()
{
if
(
widget
.
value
==
null
||
widget
.
items
==
null
||
widget
.
items
!.
isEmpty
)
{
if
(
widget
.
items
==
null
||
widget
.
items
!.
isEmpty
||
(
widget
.
value
==
null
&&
widget
.
items
!
.
where
((
DropdownMenuItem
<
T
>
item
)
=>
item
.
value
==
widget
.
value
)
.
isEmpty
))
{
_selectedIndex
=
null
;
return
;
}
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
f69b8d33
...
...
@@ -2492,7 +2492,50 @@ void main() {
expect
(
value
,
equals
(
'two'
));
});
testWidgets
(
'DropdownButton is activated with the space key'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/77655.
testWidgets
(
'DropdownButton selecting a null valued item should be selected'
,
(
WidgetTester
tester
)
async
{
final
List
<
MapEntry
<
String
?,
String
>>
items
=
<
MapEntry
<
String
?,
String
>>[
const
MapEntry
<
String
?,
String
>(
null
,
'None'
),
const
MapEntry
<
String
?,
String
>(
'one'
,
'One'
),
const
MapEntry
<
String
?,
String
>(
'two'
,
'Two'
),
];
String
?
selectedItem
=
'one'
;
await
tester
.
pumpWidget
(
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
MaterialApp
(
home:
Scaffold
(
body:
DropdownButton
<
String
>(
value:
selectedItem
,
onChanged:
(
String
?
string
)
{
setState
(()
{
selectedItem
=
string
;
});
},
items:
items
.
map
((
MapEntry
<
String
?,
String
>
item
)
{
return
DropdownMenuItem
<
String
>(
child:
Text
(
item
.
value
),
value:
item
.
key
,
);
}).
toList
(),
),
),
);
},
),
);
await
tester
.
tap
(
find
.
text
(
'One'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'None'
).
last
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'None'
),
findsOneWidget
);
});
testWidgets
(
'DropdownButton is activated with the space key'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
(
debugLabel:
'DropdownButton'
);
String
?
value
=
'one'
;
...
...
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