diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 84af479836..1d3ea6b101 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -949,6 +949,7 @@ class PopupMenuButton extends StatefulWidget { this.padding = const EdgeInsets.all(8.0), this.child, this.icon, + this.iconSize, this.offset = Offset.zero, this.enabled = true, this.shape, @@ -1048,6 +1049,11 @@ class PopupMenuButton extends StatefulWidget { /// * [Feedback] for providing platform-specific feedback to certain actions. final bool? enableFeedback; + /// If provided, the size of the [Icon]. + /// + /// If this property is null, the default size is 24.0 pixels. + final double? iconSize; + @override PopupMenuButtonState createState() => PopupMenuButtonState(); } @@ -1134,6 +1140,7 @@ class PopupMenuButtonState extends State> { return IconButton( icon: widget.icon ?? Icon(Icons.adaptive.more), padding: widget.padding, + iconSize: widget.iconSize ?? 24.0, tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip, onPressed: widget.enabled ? showButtonMenu : null, enableFeedback: enableFeedback, diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index c807b6411e..fa3b2c7a5c 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -1876,6 +1876,34 @@ void main() { expect(feedback.hapticCount, 0); }); }); + + testWidgets('iconSize parameter tests', (WidgetTester tester) async { + Future buildFrame({double? iconSize}) { + return tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Center( + child: PopupMenuButton( + iconSize: iconSize, + itemBuilder: (_) => >[ + const PopupMenuItem( + value: 'value', + child: Text('child'), + ), + ], + ), + ), + ), + ), + ); + } + + await buildFrame(); + expect(tester.widget(find.byType(IconButton)).iconSize, 24); + + await buildFrame(iconSize: 50); + expect(tester.widget(find.byType(IconButton)).iconSize, 50); + }); } class TestApp extends StatefulWidget {