mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Set the ScrollConfiguration for dropdown menus (#5255)
This commit is contained in:
parent
47139f1da9
commit
eebe09d402
@ -25,7 +25,6 @@ assets:
|
||||
- packages/flutter_gallery_assets/pesto/image9.jpg
|
||||
- packages/flutter_gallery_assets/pesto/logo_small.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/healthy.png
|
||||
- packages/flutter_gallery_assets/pesto/main.png
|
||||
|
@ -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.
|
||||
final Map<double, String> _kLogoImages = <double, String>{
|
||||
0.0: 'packages/flutter_gallery_assets/pesto/logo_small.png',
|
||||
70.0: 'packages/flutter_gallery_assets/pesto/logo_medium.png',
|
||||
170.0: 'packages/flutter_gallery_assets/pesto/logo_big.png',
|
||||
70.0: 'packages/flutter_gallery_assets/pesto/logo_medium.png'
|
||||
};
|
||||
|
||||
final ThemeData _kTheme = new ThemeData(
|
||||
|
@ -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 {
|
||||
_DropDownMenu({
|
||||
Key key,
|
||||
@ -159,12 +169,15 @@ class _DropDownMenuState<T> extends State<_DropDownMenu<T>> {
|
||||
child: new Material(
|
||||
type: MaterialType.transparency,
|
||||
textStyle: route.style,
|
||||
child: new Scrollbar(
|
||||
child: new ScrollableList(
|
||||
scrollableKey: config.route.scrollableKey,
|
||||
padding: _kMenuVerticalPadding,
|
||||
itemExtent: _kMenuItemHeight,
|
||||
children: children
|
||||
child: new ScrollConfiguration(
|
||||
delegate: _dropDownScroll,
|
||||
child: new Scrollbar(
|
||||
child: new ScrollableList(
|
||||
scrollableKey: config.route.scrollableKey,
|
||||
padding: _kMenuVerticalPadding,
|
||||
itemExtent: _kMenuItemHeight,
|
||||
children: children
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user