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
0a461894
Unverified
Commit
0a461894
authored
Feb 02, 2021
by
YeungKC
Committed by
GitHub
Feb 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Dropdown Menu (#74906)
parent
9fd3c22e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
14 deletions
+26
-14
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+7
-13
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+19
-1
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
0a461894
...
...
@@ -290,19 +290,13 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
behavior:
const
_DropdownScrollBehavior
(),
child:
PrimaryScrollController
(
controller:
widget
.
route
.
scrollController
!,
child:
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
final
double
menuTotalHeight
=
widget
.
route
.
itemHeights
.
reduce
((
double
total
,
double
height
)
=>
total
+
height
);
final
bool
isScrollable
=
kMaterialListPadding
.
vertical
+
menuTotalHeight
>
constraints
.
maxHeight
;
return
Scrollbar
(
isAlwaysShown:
isScrollable
,
child:
ListView
(
padding:
kMaterialListPadding
,
shrinkWrap:
true
,
children:
children
,
),
);
},
child:
Scrollbar
(
isAlwaysShown:
true
,
child:
ListView
(
padding:
kMaterialListPadding
,
shrinkWrap:
true
,
children:
children
,
),
),
),
),
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
0a461894
...
...
@@ -2923,13 +2923,31 @@ void main() {
testWidgets
(
'Dropdown menu should persistently show a scrollbar if it is scrollable'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
buildFrame
(
value:
'0'
,
// menu is short enough to fit onto the screen.
items:
List
<
String
>.
generate
(
/*length=*/
10
,
(
int
index
)
=>
index
.
toString
()),
onChanged:
onChanged
,
));
await
tester
.
tap
(
find
.
text
(
'0'
));
await
tester
.
pumpAndSettle
();
ScrollController
scrollController
=
PrimaryScrollController
.
of
(
tester
.
element
(
find
.
byType
(
ListView
)))!;
// The scrollbar shouldn't show if the list fits into the screen.
expect
(
scrollController
.
position
.
maxScrollExtent
,
0
);
expect
(
find
.
byType
(
Scrollbar
),
isNot
(
paints
..
rect
()));
await
tester
.
tap
(
find
.
text
(
'0'
).
last
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpWidget
(
buildFrame
(
value:
'0'
,
// menu is too long to fit onto the screen.
items:
List
<
String
>.
generate
(
/*length=*/
100
,
(
int
index
)
=>
index
.
toString
()),
onChanged:
onChanged
,
));
await
tester
.
tap
(
find
.
text
(
'0'
));
await
tester
.
pumpAndSettle
();
final
ScrollController
scrollController
=
PrimaryScrollController
.
of
(
tester
.
element
(
find
.
byType
(
ListView
)))!;
scrollController
=
PrimaryScrollController
.
of
(
tester
.
element
(
find
.
byType
(
ListView
)))!;
// The scrollbar is shown when the list is longer than the height of the screen.
expect
(
scrollController
.
position
.
maxScrollExtent
>
0
,
isTrue
);
expect
(
find
.
byType
(
Scrollbar
),
paints
..
rect
());
});
...
...
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