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
1663fde3
Unverified
Commit
1663fde3
authored
Nov 05, 2019
by
Shi-Hao Hong
Committed by
GitHub
Nov 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wire selectedItemBuilder through DropdownButtonFormField (#44160)
parent
4bf2e557
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+2
-0
dropdown_form_field_test.dart
packages/flutter/test/material/dropdown_form_field_test.dart
+44
-0
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
1663fde3
...
...
@@ -1299,6 +1299,7 @@ class DropdownButtonFormField<T> extends FormField<T> {
Key
key
,
T
value
,
@required
List
<
DropdownMenuItem
<
T
>>
items
,
DropdownButtonBuilder
selectedItemBuilder
,
Widget
hint
,
@required
this
.
onChanged
,
this
.
decoration
=
const
InputDecoration
(),
...
...
@@ -1347,6 +1348,7 @@ class DropdownButtonFormField<T> extends FormField<T> {
child:
DropdownButton
<
T
>(
value:
value
,
items:
items
,
selectedItemBuilder:
selectedItemBuilder
,
hint:
hint
,
onChanged:
onChanged
==
null
?
null
:
field
.
didChange
,
disabledHint:
disabledHint
,
...
...
packages/flutter/test/material/dropdown_form_field_test.dart
View file @
1663fde3
...
...
@@ -586,4 +586,48 @@ void main() {
);
}
});
testWidgets
(
'DropdownButtonFormField - selectedItemBuilder builds custom buttons'
,
(
WidgetTester
tester
)
async
{
const
List
<
String
>
items
=
<
String
>[
'One'
,
'Two'
,
'Three'
,
];
String
selectedItem
=
items
[
0
];
await
tester
.
pumpWidget
(
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
MaterialApp
(
home:
Scaffold
(
body:
DropdownButtonFormField
<
String
>(
value:
selectedItem
,
onChanged:
(
String
string
)
=>
setState
(()
=>
selectedItem
=
string
),
selectedItemBuilder:
(
BuildContext
context
)
{
int
index
=
0
;
return
items
.
map
((
String
string
)
{
index
+=
1
;
return
Text
(
'
$string
as an Arabic numeral:
$index
'
);
}).
toList
();
},
items:
items
.
map
((
String
string
)
{
return
DropdownMenuItem
<
String
>(
child:
Text
(
string
),
value:
string
,
);
}).
toList
(),
),
),
);
},
),
);
expect
(
find
.
text
(
'One as an Arabic numeral: 1'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'One as an Arabic numeral: 1'
));
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'Two'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Two as an Arabic numeral: 2'
),
findsOneWidget
);
});
}
\ No newline at end of file
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