Skip to content

Commit 178e444

Browse files
author
Casey Hillers
authored
Revert "Add optional flag to determine assertiveness level in aria announcement for flutter web" (#108262)
1 parent 2142b2e commit 178e444

File tree

3 files changed

+8
-35
lines changed

3 files changed

+8
-35
lines changed

packages/flutter/lib/src/semantics/semantics_event.dart

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@ import 'package:flutter/painting.dart';
88

99
export 'dart:ui' show TextDirection;
1010

11-
/// Determines the assertiveness level of the accessibility announcement.
12-
///
13-
/// It is used by [AnnounceSemanticsEvent] to determine the priority with which
14-
/// assistive technology should treat announcements.
15-
enum Assertiveness {
16-
/// The assistive technology will speak changes whenever the user is idle.
17-
polite,
18-
19-
/// The assistive technology will interrupt any announcement that it is
20-
/// currently making to notify the user about the change.
21-
///
22-
/// It should only be used for time-sensitive/critical notifications.
23-
assertive,
24-
}
25-
2611
/// An event sent by the application to notify interested listeners that
2712
/// something happened to the user interface (e.g. a view scrolled).
2813
///
@@ -86,7 +71,7 @@ abstract class SemanticsEvent {
8671
class AnnounceSemanticsEvent extends SemanticsEvent {
8772

8873
/// Constructs an event that triggers an announcement by the platform.
89-
const AnnounceSemanticsEvent(this.message, this.textDirection, {this.assertiveness = Assertiveness.polite})
74+
const AnnounceSemanticsEvent(this.message, this.textDirection)
9075
: assert(message != null),
9176
assert(textDirection != null),
9277
super('announce');
@@ -101,20 +86,11 @@ class AnnounceSemanticsEvent extends SemanticsEvent {
10186
/// This property must not be null.
10287
final TextDirection textDirection;
10388

104-
/// Determines whether the announcement should interrupt any existing announcement,
105-
/// or queue after it.
106-
///
107-
/// On the web this option uses the aria-live level to set the assertiveness
108-
/// of the announcement. On iOS, Android, Windows, Linux, macOS, and Fuchsia
109-
/// this option currently has no effect.
110-
final Assertiveness assertiveness;
111-
11289
@override
11390
Map<String, dynamic> getDataMap() {
11491
return <String, dynamic>{
11592
'message': message,
11693
'textDirection': textDirection.index,
117-
'assertiveness': assertiveness.index,
11894
};
11995
}
12096
}

packages/flutter/lib/src/semantics/semantics_service.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'dart:ui' show TextDirection;
66

77
import 'package:flutter/services.dart' show SystemChannels;
88

9-
import 'semantics_event.dart' show AnnounceSemanticsEvent, Assertiveness, TooltipSemanticsEvent;
9+
import 'semantics_event.dart' show AnnounceSemanticsEvent, TooltipSemanticsEvent;
1010

1111
export 'dart:ui' show TextDirection;
1212

@@ -29,12 +29,8 @@ class SemanticsService {
2929
///
3030
/// For example a camera application can use this method to make accessibility
3131
/// announcements regarding objects in the viewfinder.
32-
///
33-
/// The assertiveness level of the announcement is determined by [assertiveness].
34-
/// Currently, this is only supported by the web engine and has no effect on
35-
/// other platforms. The default mode is [Assertiveness.polite].
36-
static Future<void> announce(String message, TextDirection textDirection, {Assertiveness assertiveness = Assertiveness.polite}) async {
37-
final AnnounceSemanticsEvent event = AnnounceSemanticsEvent(message, textDirection, assertiveness: assertiveness);
32+
static Future<void> announce(String message, TextDirection textDirection) async {
33+
final AnnounceSemanticsEvent event = AnnounceSemanticsEvent(message, textDirection);
3834
await SystemChannels.accessibility.send(event.toMap());
3935
}
4036

packages/flutter/test/semantics/semantics_service_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ void main() {
2020
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, handleMessage);
2121

2222
await SemanticsService.announce('announcement 1', TextDirection.ltr);
23-
await SemanticsService.announce('announcement 2', TextDirection.rtl, assertiveness: Assertiveness.assertive);
23+
await SemanticsService.announce('announcement 2', TextDirection.rtl);
24+
2425
expect(log, equals(<Map<String, dynamic>>[
25-
<String, dynamic>{'type': 'announce', 'data': <String, dynamic>{'message': 'announcement 1', 'textDirection': 1, 'assertiveness': 0}},
26-
<String, dynamic>{'type': 'announce', 'data': <String, dynamic>{'message': 'announcement 2', 'textDirection': 0, 'assertiveness': 1}},
26+
<String, dynamic>{'type': 'announce', 'data': <String, dynamic>{'message': 'announcement 1', 'textDirection': 1}},
27+
<String, dynamic>{'type': 'announce', 'data': <String, dynamic>{'message': 'announcement 2', 'textDirection': 0}},
2728
]));
2829
});
2930
}

0 commit comments

Comments
 (0)