Commit e903485d authored by creativecreatorormaybenot's avatar creativecreatorormaybenot Committed by Shi-Hao Hong

Change PopupMenuButton.icon type to Widget (#43526)

parent c461ff9d
...@@ -978,11 +978,13 @@ class PopupMenuButton<T> extends StatefulWidget { ...@@ -978,11 +978,13 @@ class PopupMenuButton<T> extends StatefulWidget {
/// to set the padding to zero. /// to set the padding to zero.
final EdgeInsetsGeometry padding; 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; final Widget child;
/// If provided, the icon used for this button. /// If provided, the [icon] is used for this button
final Icon icon; /// and the button will behave like an [IconButton].
final Widget icon;
/// The offset applied to the Popup Menu Button. /// The offset applied to the Popup Menu Button.
/// ///
......
...@@ -974,6 +974,29 @@ void main() { ...@@ -974,6 +974,29 @@ void main() {
expect(find.byType(Tooltip), findsNWidgets(3)); expect(find.byType(Tooltip), findsNWidgets(3));
expect(find.byTooltip('Test 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<int>(
itemBuilder: (BuildContext context) {
return <PopupMenuEntry<int>>[
const PopupMenuItem<int>(
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 { 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