Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit a7a72ce

Browse files
authored
Fix a [CupertinoDatePicker] semantics bug (#103123)
1 parent eee051a commit a7a72ce

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

packages/flutter/lib/src/cupertino/picker.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,6 @@ class _RenderCupertinoPickerSemantics extends RenderProxyBox {
465465
}
466466

467467
void _handleDecrease() {
468-
if (_currentIndex == 0)
469-
return;
470468
controller.jumpToItem(_currentIndex - 1);
471469
}
472470

packages/flutter/test/cupertino/date_picker_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,6 +1517,37 @@ void main() {
15171517
handle.dispose();
15181518
});
15191519

1520+
// Regression test for https://github.com/flutter/flutter/issues/98567
1521+
testWidgets('picker semantics action test', (WidgetTester tester) async {
1522+
final SemanticsHandle handle = tester.ensureSemantics();
1523+
debugResetSemanticsIdCounter();
1524+
final DateTime initialDate = DateTime(2018, 6, 8);
1525+
late DateTime? date;
1526+
await tester.pumpWidget(
1527+
CupertinoApp(
1528+
home: Center(
1529+
child: SizedBox(
1530+
height: 400.0,
1531+
width: 400.0,
1532+
child: CupertinoDatePicker(
1533+
onDateTimeChanged: (DateTime newDate) => date = newDate,
1534+
initialDateTime: initialDate,
1535+
maximumDate: initialDate.add(const Duration(days: 2)),
1536+
minimumDate: initialDate.subtract(const Duration(days: 2)),
1537+
),
1538+
),
1539+
),
1540+
),
1541+
);
1542+
1543+
tester.binding.pipelineOwner.semanticsOwner!.performAction(4, SemanticsAction.decrease);
1544+
await tester.pumpAndSettle();
1545+
1546+
expect(date, DateTime(2018, 6, 7));
1547+
1548+
handle.dispose();
1549+
});
1550+
15201551
testWidgets('DatePicker adapts to MaterialApp dark mode', (WidgetTester tester) async {
15211552
Widget buildDatePicker(Brightness brightness) {
15221553
return MaterialApp(

0 commit comments

Comments
 (0)