Unverified Commit 237fc2fb authored by Hans Muller's avatar Hans Muller Committed by GitHub

PopupMenuDivider.represents() paramter must be void, not Null (#27195)

parent c082f8d8
......@@ -110,8 +110,7 @@ class PopupMenuDivider extends PopupMenuEntry<Null> {
final double height;
@override
// ignore: prefer_void_to_null, https://github.com/dart-lang/sdk/issues/34416
bool represents(Null value) => false;
bool represents(void value) => false;
@override
_PopupMenuDividerState createState() => _PopupMenuDividerState();
......
......@@ -551,6 +551,61 @@ void main() {
semantics.dispose();
});
testWidgets('PopupMenuButton PopupMenuDivider', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/27072
String selectedValue;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Container(
child: Center(
child: PopupMenuButton<String>(
onSelected: (String result) {
selectedValue = result;
},
child: const Text('Menu Button'),
initialValue: '1',
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
const PopupMenuItem<String>(
child: Text('1'),
value: '1',
),
const PopupMenuDivider(),
const PopupMenuItem<String>(
child: Text('2'),
value: '2',
),
],
),
),
),
),
),
);
await tester.tap(find.text('Menu Button'));
await tester.pumpAndSettle();
expect(find.text('1'), findsOneWidget);
expect(find.byType(PopupMenuDivider), findsOneWidget);
expect(find.text('2'), findsOneWidget);
await tester.tap(find.text('1'));
await tester.pumpAndSettle();
expect(selectedValue, '1');
await tester.tap(find.text('Menu Button'));
await tester.pumpAndSettle();
expect(find.text('1'), findsOneWidget);
expect(find.byType(PopupMenuDivider), findsOneWidget);
expect(find.text('2'), findsOneWidget);
await tester.tap(find.text('2'));
await tester.pumpAndSettle();
expect(selectedValue, '2');
});
}
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