Unverified Commit 2f657536 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Fix `DropdownButton` menu clip (#102970)

parent 90868d3b
...@@ -286,27 +286,30 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> { ...@@ -286,27 +286,30 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
namesRoute: true, namesRoute: true,
explicitChildNodes: true, explicitChildNodes: true,
label: localizations.popupMenuLabel, label: localizations.popupMenuLabel,
child: Material( child: ClipRRect(
type: MaterialType.transparency, borderRadius: widget.borderRadius ?? BorderRadius.zero,
textStyle: route.style, child: Material(
child: ScrollConfiguration( type: MaterialType.transparency,
// Dropdown menus should never overscroll or display an overscroll indicator. textStyle: route.style,
// Scrollbars are built-in below. child: ScrollConfiguration(
// Platform must use Theme and ScrollPhysics must be Clamping. // Dropdown menus should never overscroll or display an overscroll indicator.
behavior: ScrollConfiguration.of(context).copyWith( // Scrollbars are built-in below.
scrollbars: false, // Platform must use Theme and ScrollPhysics must be Clamping.
overscroll: false, behavior: ScrollConfiguration.of(context).copyWith(
physics: const ClampingScrollPhysics(), scrollbars: false,
platform: Theme.of(context).platform, overscroll: false,
), physics: const ClampingScrollPhysics(),
child: PrimaryScrollController( platform: Theme.of(context).platform,
controller: widget.route.scrollController!, ),
child: Scrollbar( child: PrimaryScrollController(
thumbVisibility: true, controller: widget.route.scrollController!,
child: ListView( child: Scrollbar(
padding: kMaterialListPadding, thumbVisibility: true,
shrinkWrap: true, child: ListView(
children: children, padding: kMaterialListPadding,
shrinkWrap: true,
children: children,
),
), ),
), ),
), ),
......
...@@ -3839,4 +3839,35 @@ void main() { ...@@ -3839,4 +3839,35 @@ void main() {
expect(tester.getBottomRight(find.text(hintText)).dx, 776.0); expect(tester.getBottomRight(find.text(hintText)).dx, 776.0);
expect(tester.getBottomRight(find.text(hintText)).dy, 350.0); expect(tester.getBottomRight(find.text(hintText)).dy, 350.0);
}); });
testWidgets('BorderRadius property clips dropdown menu', (WidgetTester tester) async {
const double radius = 20.0;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: DropdownButtonFormField<String>(
borderRadius: BorderRadius.circular(radius),
value: 'One',
items: <String>['One', 'Two', 'Three', 'Four']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (_) { },
),
),
),
),
);
await tester.tap(find.text('One'));
await tester.pumpAndSettle();
final RenderClipRRect renderClip = tester.allRenderObjects.whereType<RenderClipRRect>().first;
expect(renderClip.borderRadius, BorderRadius.circular(radius));
});
} }
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