Unverified Commit 311c0064 authored by Tirth's avatar Tirth Committed by GitHub

Adds missing `style` to `PopupMenuButton` (#143392)

Adds missing `style` to `PopupMenuButton`.

Fixes: #114709
parent bb8fc6e9
......@@ -7,6 +7,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'button_style.dart';
import 'color_scheme.dart';
import 'colors.dart';
import 'constants.dart';
......@@ -1149,6 +1150,7 @@ class PopupMenuButton<T> extends StatefulWidget {
this.clipBehavior = Clip.none,
this.useRootNavigator = false,
this.popUpAnimationStyle,
this.style,
}) : assert(
!(child != null && icon != null),
'You can only pass [child] or [icon], not both.',
......@@ -1343,6 +1345,15 @@ class PopupMenuButton<T> extends StatefulWidget {
/// If this is null, then the default animation will be used.
final AnimationStyle? popUpAnimationStyle;
/// Customizes this icon button's appearance.
///
/// The [style] is only used for Material 3 [IconButton]s. If [ThemeData.useMaterial3]
/// is set to true, [style] is preferred for icon button customization, and any
/// parameters defined in [style] will override the same parameters in [IconButton].
///
/// Null by default.
final ButtonStyle? style;
@override
PopupMenuButtonState<T> createState() => PopupMenuButtonState<T>();
}
......@@ -1455,6 +1466,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
onPressed: widget.enabled ? showButtonMenu : null,
enableFeedback: enableFeedback,
style: widget.style,
);
}
}
......
......@@ -4060,6 +4060,33 @@ void main() {
expect(listViewportBounds.bottomRight.dy, lessThanOrEqualTo(windowSize.height));
expect(listViewportBounds, overlaps(buttonBounds));
});
testWidgets('PopupMenuButton honors style', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: PopupMenuButton<int>(
style: const ButtonStyle(
iconColor: MaterialStatePropertyAll<Color>(Colors.red),
),
itemBuilder: (BuildContext context) {
return <PopupMenuItem<int>>[
const PopupMenuItem<int>(
value: 1,
child: Text('One'),
),
];
},
),
),
),
);
final RichText iconText = tester.firstWidget(find.descendant(
of: find.byType(PopupMenuButton<int>),
matching: find.byType(RichText),
));
expect(iconText.text.style?.color, Colors.red);
});
}
Matcher overlaps(Rect other) => OverlapsMatcher(other);
......
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