Unverified Commit 8d30177f authored by Chinmoy's avatar Chinmoy Committed by GitHub

Prevents DropdownButton from applying borderRadius property to the (#96695)

parent ec1a7793
...@@ -97,7 +97,6 @@ class _DropdownMenuItemButton<T> extends StatefulWidget { ...@@ -97,7 +97,6 @@ class _DropdownMenuItemButton<T> extends StatefulWidget {
const _DropdownMenuItemButton({ const _DropdownMenuItemButton({
Key? key, Key? key,
this.padding, this.padding,
required this.borderRadius,
required this.route, required this.route,
required this.buttonRect, required this.buttonRect,
required this.constraints, required this.constraints,
...@@ -111,7 +110,6 @@ class _DropdownMenuItemButton<T> extends StatefulWidget { ...@@ -111,7 +110,6 @@ class _DropdownMenuItemButton<T> extends StatefulWidget {
final BoxConstraints constraints; final BoxConstraints constraints;
final int itemIndex; final int itemIndex;
final bool enableFeedback; final bool enableFeedback;
final BorderRadius borderRadius;
@override @override
_DropdownMenuItemButtonState<T> createState() => _DropdownMenuItemButtonState<T>(); _DropdownMenuItemButtonState<T> createState() => _DropdownMenuItemButtonState<T>();
...@@ -178,16 +176,6 @@ class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>> ...@@ -178,16 +176,6 @@ class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>>
height: widget.route.itemHeight, height: widget.route.itemHeight,
child: widget.route.items[widget.itemIndex], child: widget.route.items[widget.itemIndex],
); );
final BorderRadius itemBorderRadius;
if (widget.route.items.length == 1) {
itemBorderRadius = widget.borderRadius;
} else if (widget.itemIndex == 0) {
itemBorderRadius = BorderRadius.only(topLeft: widget.borderRadius.topLeft, topRight: widget.borderRadius.topRight);
} else if (widget.itemIndex == widget.route.items.length - 1) {
itemBorderRadius = BorderRadius.only(bottomLeft: widget.borderRadius.bottomLeft, bottomRight: widget.borderRadius.bottomRight);
} else {
itemBorderRadius = BorderRadius.zero;
}
// An [InkWell] is added to the item only if it is enabled // An [InkWell] is added to the item only if it is enabled
if (dropdownMenuItem.enabled) { if (dropdownMenuItem.enabled) {
child = InkWell( child = InkWell(
...@@ -195,7 +183,6 @@ class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>> ...@@ -195,7 +183,6 @@ class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>>
enableFeedback: widget.enableFeedback, enableFeedback: widget.enableFeedback,
onTap: _handleOnTap, onTap: _handleOnTap,
onFocusChange: _handleFocusChange, onFocusChange: _handleFocusChange,
borderRadius: itemBorderRadius,
child: child, child: child,
); );
} }
...@@ -279,7 +266,6 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> { ...@@ -279,7 +266,6 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
constraints: widget.constraints, constraints: widget.constraints,
itemIndex: itemIndex, itemIndex: itemIndex,
enableFeedback: widget.enableFeedback, enableFeedback: widget.enableFeedback,
borderRadius: widget.borderRadius ?? BorderRadius.zero,
), ),
]; ];
...@@ -1113,11 +1099,6 @@ class DropdownButton<T> extends StatefulWidget { ...@@ -1113,11 +1099,6 @@ class DropdownButton<T> extends StatefulWidget {
final AlignmentGeometry alignment; final AlignmentGeometry alignment;
/// Defines the corner radii of the menu's rounded rectangle shape. /// Defines the corner radii of the menu's rounded rectangle shape.
///
/// The radii of the first menu item's top left and right corners are
/// defined by the corresponding properties of the [borderRadius].
/// Similarly, the radii of the last menu item's bottom and right corners
/// are defined by the corresponding properties of the [borderRadius].
final BorderRadius? borderRadius; final BorderRadius? borderRadius;
@override @override
......
...@@ -3564,43 +3564,6 @@ void main() { ...@@ -3564,43 +3564,6 @@ void main() {
..rrect() ..rrect()
..rrect(rrect: const RRect.fromLTRBXY(0.0, 0.0, 144.0, 208.0, radius, radius)), ..rrect(rrect: const RRect.fromLTRBXY(0.0, 0.0, 144.0, 208.0, radius, radius)),
); );
final InkWell firstItem = tester.widget(find.widgetWithText(InkWell, 'One'));
final InkWell lastItem = tester.widget(find.widgetWithText(InkWell, 'Four'));
expect(firstItem.borderRadius, const BorderRadius.vertical(top: Radius.circular(radius)));
expect(lastItem.borderRadius, const BorderRadius.vertical(bottom: Radius.circular(radius)));
});
testWidgets('borderRadius is properly applied to InkWell when there is only one item', (WidgetTester tester) async {
const BorderRadius borderRadius = BorderRadius.all(Radius.circular(5.0));
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: DropdownButton<String>(
borderRadius: borderRadius,
value: 'One',
items: const <DropdownMenuItem<String>>[
DropdownMenuItem<String>(
value: 'One',
child: Text('One')
),
],
onChanged: (_) { },
),
),
),
),
);
await tester.tap(find.text('One'));
await tester.pumpAndSettle();
final InkWell menuItem = tester.widget(find.widgetWithText(InkWell, 'One'));
expect(menuItem.borderRadius, borderRadius);
}); });
// Regression test for https://github.com/flutter/flutter/issues/88574 // Regression test for https://github.com/flutter/flutter/issues/88574
...@@ -3718,11 +3681,5 @@ void main() { ...@@ -3718,11 +3681,5 @@ void main() {
..rrect() ..rrect()
..rrect(rrect: const RRect.fromLTRBXY(0.0, 0.0, 800.0, 208.0, radius, radius)), ..rrect(rrect: const RRect.fromLTRBXY(0.0, 0.0, 800.0, 208.0, radius, radius)),
); );
final InkWell firstItem = tester.widget(find.widgetWithText(InkWell, 'One'));
final InkWell lastItem = tester.widget(find.widgetWithText(InkWell, 'Four'));
expect(firstItem.borderRadius, const BorderRadius.vertical(top: Radius.circular(radius)));
expect(lastItem.borderRadius, const BorderRadius.vertical(bottom: Radius.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