Fixed a bug with the month grid showing the wrong month after selecting a date. (#53594)

This commit is contained in:
Darren Austin 2020-03-30 13:45:33 -07:00 committed by GitHub
parent 08ee37e1c1
commit c7a6e300dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -592,7 +592,6 @@ class _MonthPickerState extends State<_MonthPicker> {
_DayHeaders(),
Expanded(
child: PageView.builder(
key: ValueKey<DateTime>(widget.selectedDate),
controller: _pageController,
itemBuilder: _buildItems,
itemCount: utils.monthDelta(widget.firstDate, widget.lastDate) + 1,

View File

@ -278,6 +278,20 @@ void main() {
});
});
testWidgets('Selecting date does not change displayed month', (WidgetTester tester) async {
initialDate = DateTime(2020, DateTime.march, 15);
await prepareDatePicker(tester, (Future<DateTime> date) async {
await tester.tap(nextMonthIcon);
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('April 2020'), findsOneWidget);
await tester.tap(find.text('25'));
await tester.pumpAndSettle();
expect(find.text('April 2020'), findsOneWidget);
// There isn't a 31 in April so there shouldn't be one if it is showing April
expect(find.text('31'), findsNothing);
});
});
testWidgets('Changing year does not change selected date', (WidgetTester tester) async {
await prepareDatePicker(tester, (Future<DateTime> date) async {
await tester.tap(find.text('January 2016'));