Unverified Commit ac2f62a9 authored by Pedro Massango's avatar Pedro Massango Committed by GitHub

Provide a way to change the default PopupMenuButton's icon size (#68000)

parent 737824db
......@@ -949,6 +949,7 @@ class PopupMenuButton<T> 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<T> 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<T> createState() => PopupMenuButtonState<T>();
}
......@@ -1134,6 +1140,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
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,
......
......@@ -1876,6 +1876,34 @@ void main() {
expect(feedback.hapticCount, 0);
});
});
testWidgets('iconSize parameter tests', (WidgetTester tester) async {
Future<void> buildFrame({double? iconSize}) {
return tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: PopupMenuButton<String>(
iconSize: iconSize,
itemBuilder: (_) => <PopupMenuEntry<String>>[
const PopupMenuItem<String>(
value: 'value',
child: Text('child'),
),
],
),
),
),
),
);
}
await buildFrame();
expect(tester.widget<IconButton>(find.byType(IconButton)).iconSize, 24);
await buildFrame(iconSize: 50);
expect(tester.widget<IconButton>(find.byType(IconButton)).iconSize, 50);
});
}
class TestApp extends StatefulWidget {
......
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