From e903485de22d2c396faebe3a316b42bd1959e66a Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot <19204050+creativecreatorormaybenot@users.noreply.github.com> Date: Mon, 28 Oct 2019 20:46:14 +0000 Subject: [PATCH] Change PopupMenuButton.icon type to Widget (#43526) --- .../flutter/lib/src/material/popup_menu.dart | 8 ++++--- .../test/material/popup_menu_test.dart | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 2c992fc25c..b1deb595c0 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -978,11 +978,13 @@ class PopupMenuButton extends StatefulWidget { /// to set the padding to zero. final EdgeInsetsGeometry padding; - /// If provided, the widget used for this button. + /// If provided, [child] is the widget used for this button + /// and the button will utilize an [InkWell] for taps. final Widget child; - /// If provided, the icon used for this button. - final Icon icon; + /// If provided, the [icon] is used for this button + /// and the button will behave like an [IconButton]. + final Widget icon; /// The offset applied to the Popup Menu Button. /// diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index 6b958aeb43..d05abe72bd 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -974,6 +974,29 @@ void main() { expect(find.byType(Tooltip), findsNWidgets(3)); expect(find.byTooltip('Test tooltip',), findsNWidgets(3)); }); + + testWidgets('Allow Widget for PopupMenuButton.icon', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + home: Material( + child: PopupMenuButton( + itemBuilder: (BuildContext context) { + return >[ + const PopupMenuItem( + value: 1, + child: Text('Tap me please!'), + ), + ]; + }, + tooltip: 'Test tooltip', + icon: const Text('PopupMenuButton icon'), + ), + ), + ), + ); + + expect(find.text('PopupMenuButton icon'), findsOneWidget); + }); } class TestApp extends StatefulWidget {