Fix Gallery subtitle not updating correctly upon selection (#73303)

This commit is contained in:
xubaolin
2021-01-05 23:27:59 +08:00
committed by GitHub
parent a293c82251
commit 27b7ec348c
2 changed files with 20 additions and 1 deletions

View File

@@ -43,7 +43,7 @@ class MenuDemoState extends State<MenuDemo> {
void showMenuSelection(String value) {
if (<String>[_simpleValue1, _simpleValue2, _simpleValue3].contains(value))
_simpleValue = value;
setState(() => _simpleValue = value);
showInSnackBar('You selected: $value');
}

View File

@@ -29,4 +29,23 @@ void main() {
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: find.byWidgetPredicate((Widget widget) => widget is Icon))));
});
testWidgets('The selected menu item update test', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: kDarkGalleryTheme,
home: const MenuDemo(),
));
// Popup the menu.
await tester.tap(find.text('An item with a simple menu'));
await tester.pumpAndSettle();
// Select one item.
await tester.tap(find.text('Menu item value three'));
await tester.pumpAndSettle();
// The subtitle updated with the selected item.
expect(find.text('Menu item value three'), findsOneWidget);
});
}