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
db096cdf
Commit
db096cdf
authored
Mar 21, 2019
by
Shayne Kelly II
Committed by
Hans Muller
Mar 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DropdownButton underline to be customizable (#29138)
parent
a4b9ef2e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+7
-1
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+28
-0
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
db096cdf
...
...
@@ -599,6 +599,7 @@ class DropdownButton<T> extends StatefulWidget {
@required
this
.
onChanged
,
this
.
elevation
=
8
,
this
.
style
,
this
.
underline
,
this
.
icon
,
this
.
iconDisabledColor
,
this
.
iconEnabledColor
,
...
...
@@ -656,6 +657,11 @@ class DropdownButton<T> extends StatefulWidget {
/// [ThemeData.textTheme] of the current [Theme].
final
TextStyle
style
;
/// The widget to use for drawing the drop-down button's underline.
///
/// Defaults to a 0.0 width bottom border with color 0xFFBDBDBD.
final
Widget
underline
;
/// The widget to use for the drop-down button's icon.
///
/// Defaults to an [Icon] with the [Icons.arrow_drop_down] glyph.
...
...
@@ -897,7 +903,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
left:
0.0
,
right:
0.0
,
bottom:
bottom
,
child:
Container
(
child:
widget
.
underline
??
Container
(
height:
1.0
,
decoration:
const
BoxDecoration
(
border:
Border
(
bottom:
BorderSide
(
color:
Color
(
0xFFBDBDBD
),
width:
0.0
))
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
db096cdf
...
...
@@ -39,6 +39,7 @@ Widget buildFrame({
bool
isExpanded
=
false
,
Widget
hint
,
Widget
disabledHint
,
Widget
underline
,
List
<
String
>
items
=
menuItems
,
Alignment
alignment
=
Alignment
.
center
,
TextDirection
textDirection
=
TextDirection
.
ltr
,
...
...
@@ -61,6 +62,7 @@ Widget buildFrame({
iconEnabledColor:
iconEnabledColor
,
isDense:
isDense
,
isExpanded:
isExpanded
,
underline:
underline
,
items:
items
==
null
?
null
:
items
.
map
<
DropdownMenuItem
<
String
>>((
String
item
)
{
return
DropdownMenuItem
<
String
>(
key:
ValueKey
<
String
>(
item
),
...
...
@@ -1223,4 +1225,30 @@ void main() {
await
tester
.
pumpAndSettle
();
expect
(
selectedIndex
,
13
);
});
testWidgets
(
'Dropdown button will accept widgets as its underline'
,
(
WidgetTester
tester
)
async
{
const
BoxDecoration
decoration
=
BoxDecoration
(
border:
Border
(
bottom:
BorderSide
(
color:
Color
(
0xFFCCBB00
),
width:
4.0
)),
);
const
BoxDecoration
defaultDecoration
=
BoxDecoration
(
border:
Border
(
bottom:
BorderSide
(
color:
Color
(
0xFFBDBDBD
),
width:
0.0
)),
);
final
Widget
customUnderline
=
Container
(
height:
4.0
,
decoration:
decoration
);
final
Key
buttonKey
=
UniqueKey
();
final
Finder
decoratedBox
=
find
.
descendant
(
of:
find
.
byKey
(
buttonKey
),
matching:
find
.
byType
(
DecoratedBox
),
);
await
tester
.
pumpWidget
(
buildFrame
(
buttonKey:
buttonKey
,
underline:
customUnderline
,
value:
'two'
,
onChanged:
onChanged
));
expect
(
tester
.
widget
<
DecoratedBox
>(
decoratedBox
).
decoration
,
decoration
);
await
tester
.
pumpWidget
(
buildFrame
(
buttonKey:
buttonKey
,
value:
'two'
,
onChanged:
onChanged
));
expect
(
tester
.
widget
<
DecoratedBox
>(
decoratedBox
).
decoration
,
defaultDecoration
);
});
}
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