announce static method
- @Deprecated('Use sendAnnouncement instead. ' 'This API is incompatible with multiple windows. ' 'This feature was deprecated after v3.35.0-0.1.pre.')
- String message,
- TextDirection textDirection, {
- Assertiveness assertiveness = Assertiveness.polite,
Sends a semantic announcement.
This method is deprecated. Prefer using sendAnnouncement instead.
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 it is supported using MediaQuery.supportsAnnounceOf 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
@Deprecated(
'Use sendAnnouncement instead. '
'This API is incompatible with multiple windows. '
'This feature was deprecated after v3.35.0-0.1.pre.',
)
static Future<void> announce(
String message,
TextDirection textDirection, {
Assertiveness assertiveness = Assertiveness.polite,
}) async {
final FlutterView? view = PlatformDispatcher.instance.implicitView;
assert(
view != null,
'SemanticsService.announce is incompatible with multiple windows. '
'Use SemanticsService.sendAnnouncement instead.',
);
final AnnounceSemanticsEvent event = AnnounceSemanticsEvent(
message,
textDirection,
view!.viewId,
assertiveness: assertiveness,
);
await SystemChannels.accessibility.send(event.toMap());
}