diff --git a/packages/flutter/lib/src/cupertino/picker.dart b/packages/flutter/lib/src/cupertino/picker.dart index de1884b71a95..1020522a5f40 100644 --- a/packages/flutter/lib/src/cupertino/picker.dart +++ b/packages/flutter/lib/src/cupertino/picker.dart @@ -465,8 +465,6 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox { } void _handleDecrease() { - if (_currentIndex == 0) - return; controller.jumpToItem(_currentIndex - 1); } diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 5a2667fdfa62..73ce7200bfec 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -1517,6 +1517,37 @@ void main() { handle.dispose(); }); + // Regression test for https://github.com/flutter/flutter/issues/98567 + testWidgets('picker semantics action test', (WidgetTester tester) async { + final SemanticsHandle handle = tester.ensureSemantics(); + debugResetSemanticsIdCounter(); + final DateTime initialDate = DateTime(2018, 6, 8); + late DateTime? date; + await tester.pumpWidget( + CupertinoApp( + home: Center( + child: SizedBox( + height: 400.0, + width: 400.0, + child: CupertinoDatePicker( + onDateTimeChanged: (DateTime newDate) => date = newDate, + initialDateTime: initialDate, + maximumDate: initialDate.add(const Duration(days: 2)), + minimumDate: initialDate.subtract(const Duration(days: 2)), + ), + ), + ), + ), + ); + + tester.binding.pipelineOwner.semanticsOwner!.performAction(4, SemanticsAction.decrease); + await tester.pumpAndSettle(); + + expect(date, DateTime(2018, 6, 7)); + + handle.dispose(); + }); + testWidgets('DatePicker adapts to MaterialApp dark mode', (WidgetTester tester) async { Widget buildDatePicker(Brightness brightness) { return MaterialApp(