Unverified Commit c7a6e300 authored by Darren Austin's avatar Darren Austin Committed by GitHub

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

parent 08ee37e1
......@@ -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,
......
......@@ -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'));
......
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