announce static method

Future<void> announce(
  1. String message,
  2. TextDirection textDirection, {
  3. Assertiveness assertiveness = Assertiveness.polite,
})

Sends a semantic announcement.

This should be used for announcement that are not seamlessly announced by the system as a result of a UI state change.

For example a camera application can use this method to make accessibility announcements regarding objects in the viewfinder.

The assertiveness level of the announcement is determined by assertiveness. Currently, this is only supported by the web engine and has no effect on other platforms. The default mode is Assertiveness.polite.

Not all platforms support announcements. Check to see if isAnnounceSupported before calling this method.

Android

Android has deprecated announcement events due to its disruptive behavior with TalkBack forcing it to clear its speech queue and speak the provided text. Instead, use mechanisms like Semantics to implicitly trigger announcements.

Implementation

static Future<void> announce(
  String message,
  TextDirection textDirection, {
  Assertiveness assertiveness = Assertiveness.polite,
}) async {
  final AnnounceSemanticsEvent event = AnnounceSemanticsEvent(
    message,
    textDirection,
    assertiveness: assertiveness,
  );
  await SystemChannels.accessibility.send(event.toMap());
}