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
7eeab266
Unverified
Commit
7eeab266
authored
Oct 14, 2020
by
xubaolin
Committed by
GitHub
Oct 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix DropdownButton bug (#65915)
parent
66cf8d47
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+6
-10
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+1
-1
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
7eeab266
...
...
@@ -1303,16 +1303,12 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
// The width of the button and the menu are defined by the widest
// item and the width of the hint.
List
<
Widget
>
items
;
if
(
_enabled
)
{
items
=
widget
.
selectedItemBuilder
==
null
?
List
<
Widget
>.
from
(
widget
.
items
!)
:
widget
.
selectedItemBuilder
!(
context
);
}
else
{
items
=
widget
.
selectedItemBuilder
==
null
?
<
Widget
>[]
:
widget
.
selectedItemBuilder
!(
context
);
}
// We should explicitly type the items list to be a list of <Widget>,
// otherwise, no explicit type adding items maybe trigger a crash/failure
// when hint and selectedItemBuilder are provided.
final
List
<
Widget
>
items
=
widget
.
selectedItemBuilder
==
null
?
(
_enabled
?
List
<
Widget
>.
from
(
widget
.
items
!)
:
<
Widget
>[])
:
List
<
Widget
>.
from
(
widget
.
selectedItemBuilder
!(
context
));
int
?
hintIndex
;
if
(
widget
.
hint
!=
null
||
(!
_enabled
&&
widget
.
disabledHint
!=
null
))
{
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
7eeab266
...
...
@@ -1945,7 +1945,7 @@ void main() {
});
},
selectedItemBuilder:
(
BuildContext
context
)
{
return
items
.
map
<
Widget
>
((
String
item
)
{
return
items
.
map
((
String
item
)
{
return
Text
(
'You have selected:
$item
'
);
}).
toList
();
},
...
...
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