Skip to content

Commit 8496dcc

Browse files
authored
Merge pull request #127 from gabrielezereik/fix/accessibility-labels
Fix/accessibility labels
2 parents d9eb4c5 + 0be5d82 commit 8496dcc

File tree

5 files changed

+60
-23
lines changed

5 files changed

+60
-23
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 6.7.2 - 2026-02-26
2+
- Added semantics support (`previousButtonSemanticsLabel`, `nextButtonSemanticsLabel`) to header navigation arrows via `PickerHeaderSettings`.
3+
14
## 6.7.1 - 2026-01-19
25
- Added operation order fix from [Jerrywell](https://github.com/jerrywellcake) fork.
36

lib/src/helpers/settings/header_settings.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class PickerHeaderSettings {
1616
this.headerPadding = const EdgeInsets.all(16.0),
1717
this.arrowAlpha = 0.5,
1818
this.headerAlignment = CrossAxisAlignment.start,
19+
this.previousButtonSemanticsLabel,
20+
this.nextButtonSemanticsLabel,
1921
});
2022

2123
/// Hides the row with the arrows + years/months page range from the header, forcing the user to scroll to change the page.
@@ -85,6 +87,16 @@ class PickerHeaderSettings {
8587
/// default: `CrossAxisAlignment.start`
8688
final CrossAxisAlignment headerAlignment;
8789

90+
/// The semantics label of the previous button.
91+
///
92+
/// default: `null`
93+
final String? previousButtonSemanticsLabel;
94+
95+
/// The semantics label of the next button.
96+
///
97+
/// default: `null`
98+
final String? nextButtonSemanticsLabel;
99+
88100
PickerHeaderSettings copyWith({
89101
bool? hideHeaderRow,
90102
bool? hideHeaderArrows,

lib/src/month_picker_widgets/header/header_arrows.dart

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class HeaderArrows extends StatelessWidget {
1414
this.nextIcon,
1515
required this.arrowAlpha,
1616
required this.verticalScrolling,
17+
this.previousButtonSemanticsLabel,
18+
this.nextButtonSemanticsLabel,
1719
});
1820
final Color? arrowcolors;
1921
final double? arrowSize;
@@ -23,37 +25,51 @@ class HeaderArrows extends StatelessWidget {
2325
final IconData? previousIcon;
2426
final IconData? nextIcon;
2527
final bool verticalScrolling;
28+
final String? previousButtonSemanticsLabel;
29+
final String? nextButtonSemanticsLabel;
2630

2731
@override
2832
Widget build(BuildContext context) {
2933
return Row(
3034
mainAxisSize: MainAxisSize.min,
3135
children: <Widget>[
32-
IconButton(
33-
icon: Icon(
34-
previousIcon ??
35-
(verticalScrolling
36-
? Icons.keyboard_arrow_up
37-
: Icons.keyboard_arrow_left),
38-
color: upState
39-
? arrowcolors
40-
: arrowcolors!.withValues(alpha: arrowAlpha),
41-
size: arrowSize,
36+
Semantics(
37+
label: previousButtonSemanticsLabel ??
38+
MaterialLocalizations.of(context).previousMonthTooltip,
39+
button: true,
40+
excludeSemantics: true,
41+
child: IconButton(
42+
icon: Icon(
43+
previousIcon ??
44+
(verticalScrolling
45+
? Icons.keyboard_arrow_up
46+
: Icons.keyboard_arrow_left),
47+
color: upState
48+
? arrowcolors
49+
: arrowcolors!.withValues(alpha: arrowAlpha),
50+
size: arrowSize,
51+
),
52+
onPressed: upState ? onUpButtonPressed : null,
4253
),
43-
onPressed: upState ? onUpButtonPressed : null,
4454
),
45-
IconButton(
46-
icon: Icon(
47-
nextIcon ??
48-
(verticalScrolling
49-
? Icons.keyboard_arrow_down
50-
: Icons.keyboard_arrow_right),
51-
color: downState
52-
? arrowcolors
53-
: arrowcolors!.withValues(alpha: arrowAlpha),
54-
size: arrowSize,
55+
Semantics(
56+
label: nextButtonSemanticsLabel ??
57+
MaterialLocalizations.of(context).nextMonthTooltip,
58+
button: true,
59+
excludeSemantics: true,
60+
child: IconButton(
61+
icon: Icon(
62+
nextIcon ??
63+
(verticalScrolling
64+
? Icons.keyboard_arrow_down
65+
: Icons.keyboard_arrow_right),
66+
color: downState
67+
? arrowcolors
68+
: arrowcolors!.withValues(alpha: arrowAlpha),
69+
size: arrowSize,
70+
),
71+
onPressed: downState ? onDownButtonPressed : null,
5572
),
56-
onPressed: downState ? onDownButtonPressed : null,
5773
),
5874
],
5975
);

lib/src/month_picker_widgets/header/header_row.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ class HeaderRow extends StatelessWidget {
7979
.monthPickerDialogSettings.headerSettings.arrowAlpha,
8080
verticalScrolling: controller
8181
.monthPickerDialogSettings.dialogSettings.verticalScrolling,
82+
previousButtonSemanticsLabel: controller
83+
.monthPickerDialogSettings
84+
.headerSettings
85+
.previousButtonSemanticsLabel,
86+
nextButtonSemanticsLabel: controller.monthPickerDialogSettings
87+
.headerSettings.nextButtonSemanticsLabel,
8288
),
8389
]
8490
: <Widget>[

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: month_picker_dialog
22
description: Internationalized dialog for picking a single month from an infinite list of years.
3-
version: 6.7.1
3+
version: 6.7.2
44
homepage: https://github.com/Macacoazul01/month_picker_dialog
55

66
environment:

0 commit comments

Comments
 (0)