@@ -8,6 +8,21 @@ import 'package:flutter/painting.dart';
88
99export '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+
1126/// An event sent by the application to notify interested listeners that
1227/// something happened to the user interface (e.g. a view scrolled).
1328///
@@ -71,7 +86,7 @@ abstract class SemanticsEvent {
7186class AnnounceSemanticsEvent extends SemanticsEvent {
7287
7388 /// Constructs an event that triggers an announcement by the platform.
74- const AnnounceSemanticsEvent (this .message, this .textDirection)
89+ const AnnounceSemanticsEvent (this .message, this .textDirection, { this .assertiveness = Assertiveness .polite} )
7590 : assert (message != null ),
7691 assert (textDirection != null ),
7792 super ('announce' );
@@ -86,11 +101,20 @@ class AnnounceSemanticsEvent extends SemanticsEvent {
86101 /// This property must not be null.
87102 final TextDirection textDirection;
88103
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+
89112 @override
90113 Map <String , dynamic > getDataMap () {
91114 return < String , dynamic > {
92115 'message' : message,
93116 'textDirection' : textDirection.index,
117+ 'assertiveness' : assertiveness.index,
94118 };
95119 }
96120}
0 commit comments