Change PopupMenuButton.icon type to Widget (#43526)

This commit is contained in:
creativecreatorormaybenot 2019-10-28 20:46:14 +00:00 committed by Shi-Hao Hong
parent c461ff9d4a
commit e903485de2
2 changed files with 28 additions and 3 deletions

View File

@ -978,11 +978,13 @@ class PopupMenuButton<T> 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.
///

View File

@ -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<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 {