-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Update the AccessibilityPlugin::Announce method to account for the view #172669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
29aa8c9
6d98c0a
0de9a8e
6e9a70d
d62d1eb
118d90a
d1d01ef
d22a5fd
a19e5b3
802bfab
4ec6112
5f658d9
b2e94ec
b11f8dc
39a0cc9
eb6030f
bd64992
9411e54
89b7b26
97da60b
af94bf8
99eac77
06ccc12
5e35a77
b5f5c08
832464d
0900f69
7feec64
cacccdd
2385e37
3c4be84
2989524
04f3ea0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| /// @docImport 'package:flutter/widgets.dart'; | ||
| library; | ||
|
|
||
| import 'dart:ui' show TextDirection; | ||
| import 'dart:ui' show FlutterView, PlatformDispatcher, TextDirection; | ||
|
|
||
| import 'package:flutter/services.dart' show SystemChannels; | ||
|
|
||
|
|
@@ -23,6 +23,9 @@ export 'dart:ui' show TextDirection; | |
| abstract final class SemanticsService { | ||
| /// Sends a semantic announcement. | ||
| /// | ||
| /// This method is deprecated. Prefer using [sendAnnouncement] instead. | ||
| /// | ||
| /// {@template flutter.semantics.service.announce} | ||
| /// This should be used for announcement that are not seamlessly announced by | ||
| /// the system as a result of a UI state change. | ||
| /// | ||
|
|
@@ -43,15 +46,48 @@ abstract final class SemanticsService { | |
| /// trigger announcements. | ||
| /// | ||
| /// [1]: https://developer.android.com/reference/android/view/View#announceForAccessibility(java.lang.CharSequence) | ||
| /// {@endtemplate} | ||
| /// | ||
| @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, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will the PlatformDispatcher.instance.implicitView be null in multiwindow app?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now no, but in the future (likely at least 1 year from now) yes. Currently, the runner app creates the initial window and gives it to Flutter to render into - this is the implicit view. This app with an implicit view can have multiple windows. In the future - after Flutter supports multiple windows - Flutter will create all windows on desktop, including the initial window. Thus, there'll be no implicit view. Existing apps will need to migrate their native entry point to opt-in to this new behavior. I expect that by the time the implicit view can be null, this API will have been deprecated long enough that it'll be reasonable for us to trigger this assert. |
||
| '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()); | ||
| } | ||
|
|
||
| /// Sends a semantic announcement for a particular view. | ||
| /// | ||
| /// One can use [View.of] to get the current [FlutterView]. | ||
| /// | ||
|
mattkae marked this conversation as resolved.
|
||
| /// {@macro flutter.semantics.service.announce} | ||
| static Future<void> sendAnnouncement( | ||
|
loic-sharma marked this conversation as resolved.
|
||
| FlutterView view, | ||
| String message, | ||
| TextDirection textDirection, { | ||
| Assertiveness assertiveness = Assertiveness.polite, | ||
| }) async { | ||
| final AnnounceSemanticsEvent event = AnnounceSemanticsEvent( | ||
| message, | ||
| textDirection, | ||
| view.viewId, | ||
| assertiveness: assertiveness, | ||
| ); | ||
| await SystemChannels.accessibility.send(event.toMap()); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.