Commit eebe09d4 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Set the ScrollConfiguration for dropdown menus (#5255)

parent 47139f1d
...@@ -25,7 +25,6 @@ assets: ...@@ -25,7 +25,6 @@ assets:
- packages/flutter_gallery_assets/pesto/image9.jpg - packages/flutter_gallery_assets/pesto/image9.jpg
- packages/flutter_gallery_assets/pesto/logo_small.png - packages/flutter_gallery_assets/pesto/logo_small.png
- packages/flutter_gallery_assets/pesto/logo_medium.png - packages/flutter_gallery_assets/pesto/logo_medium.png
- packages/flutter_gallery_assets/pesto/logo_big.png
- packages/flutter_gallery_assets/pesto/fish.png - packages/flutter_gallery_assets/pesto/fish.png
- packages/flutter_gallery_assets/pesto/healthy.png - packages/flutter_gallery_assets/pesto/healthy.png
- packages/flutter_gallery_assets/pesto/main.png - packages/flutter_gallery_assets/pesto/main.png
......
...@@ -12,8 +12,7 @@ const String _kUserImage = 'packages/flutter_gallery_assets/pesto/avatar.jpg'; ...@@ -12,8 +12,7 @@ const String _kUserImage = 'packages/flutter_gallery_assets/pesto/avatar.jpg';
// Map of logo images keyed by the minimum height their container needs to be. // Map of logo images keyed by the minimum height their container needs to be.
final Map<double, String> _kLogoImages = <double, String>{ final Map<double, String> _kLogoImages = <double, String>{
0.0: 'packages/flutter_gallery_assets/pesto/logo_small.png', 0.0: 'packages/flutter_gallery_assets/pesto/logo_small.png',
70.0: 'packages/flutter_gallery_assets/pesto/logo_medium.png', 70.0: 'packages/flutter_gallery_assets/pesto/logo_medium.png'
170.0: 'packages/flutter_gallery_assets/pesto/logo_big.png',
}; };
final ThemeData _kTheme = new ThemeData( final ThemeData _kTheme = new ThemeData(
......
...@@ -75,6 +75,16 @@ class _DropDownMenuPainter extends CustomPainter { ...@@ -75,6 +75,16 @@ class _DropDownMenuPainter extends CustomPainter {
} }
} }
// Do not use the platform-specific default scroll configuration.
// Dropdown menus should never overscroll or display an overscroll indicator.
class _DropDownScrollConfigurationDelegate extends ScrollConfigurationDelegate {
const _DropDownScrollConfigurationDelegate();
@override
Widget wrapScrollWidget(Widget scrollWidget) => new ClampOverscrolls(value: true, child: scrollWidget);
}
final ScrollConfigurationDelegate _dropDownScroll = const _DropDownScrollConfigurationDelegate();
class _DropDownMenu<T> extends StatefulWidget { class _DropDownMenu<T> extends StatefulWidget {
_DropDownMenu({ _DropDownMenu({
Key key, Key key,
...@@ -159,12 +169,15 @@ class _DropDownMenuState<T> extends State<_DropDownMenu<T>> { ...@@ -159,12 +169,15 @@ class _DropDownMenuState<T> extends State<_DropDownMenu<T>> {
child: new Material( child: new Material(
type: MaterialType.transparency, type: MaterialType.transparency,
textStyle: route.style, textStyle: route.style,
child: new Scrollbar( child: new ScrollConfiguration(
child: new ScrollableList( delegate: _dropDownScroll,
scrollableKey: config.route.scrollableKey, child: new Scrollbar(
padding: _kMenuVerticalPadding, child: new ScrollableList(
itemExtent: _kMenuItemHeight, scrollableKey: config.route.scrollableKey,
children: children padding: _kMenuVerticalPadding,
itemExtent: _kMenuItemHeight,
children: children
)
) )
) )
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment