public class AccessibilityBridge extends AccessibilityNodeProvider
View, called the
rootAccessibilityView, which contains a Flutter UI. The
rootAccessibilityViewis required at the time of
AccessibilityBridge's instantiation and is held for the duration of
AccessibilityBridgeinvokes various accessibility methods on the
rootAccessibilityViewis expected to notify the
AccessibilityBridgeof relevant interactions:
updateSemantics(ByteBuffer, String, ByteBuffer), and
AccessibilityChannelthat is connected to the running Flutter app.
AccessibilityManagerto query and listen for accessibility settings.
ContentResolverto listen for changes to system animation settings.
AccessibilityBridgecauses Android to treat Flutter
SemanticsNodes as if they were accessible Android
Views. Accessibility requests may be sent from a Flutter widget to the Android OS, as if it were an Android
View, and accessibility events may be consumed by a Flutter widget, as if it were an Android
AccessibilityBridgerefers to Flutter's accessible widgets as "virtual views" and identifies them with "virtual view IDs".
|Modifier and Type||Class and Description|
Listener that can be set on a
|Constructor and Description|
|Modifier and Type||Method and Description|
Delegates handling of
Finds the view in a hierarchy that currently has the given type of
Returns true if the Android OS currently has accessibility enabled, false otherwise.
Returns true if the Android OS currently has touch exploration enabled, false otherwise.
Instructs the view represented by
Disconnects any listeners and/or delegates that were initialized in
Sets a listener on this
public AccessibilityBridge(@NonNull View rootAccessibilityView, @NonNull AccessibilityChannel accessibilityChannel, @NonNull AccessibilityManager accessibilityManager, @NonNull ContentResolver contentResolver, PlatformViewsAccessibilityDelegate platformViewsAccessibilityDelegate)
public AccessibilityBridge(@NonNull View rootAccessibilityView, @NonNull AccessibilityChannel accessibilityChannel, @NonNull AccessibilityManager accessibilityManager, @NonNull ContentResolver contentResolver, @NonNull io.flutter.view.AccessibilityViewEmbedder accessibilityViewEmbedder, PlatformViewsAccessibilityDelegate platformViewsAccessibilityDelegate)
public int getHoveredObjectId()
public void release()
AccessibilityBridge's constructor, or added after.
Do not use this instance after invoking
release. The behavior of any method invoked
AccessibilityBridge after invoking
release() is undefined.
public boolean isAccessibilityEnabled()
public boolean isTouchExplorationEnabled()
public void setOnAccessibilityChangeListener(@Nullable AccessibilityBridge.OnAccessibilityChangeListener listener)
AccessibilityBridge, which is notified whenever accessibility activation, or touch exploration activation changes.
public AccessibilityNodeInfo obtainAccessibilityNodeInfo(View rootView, int virtualViewId)
public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId)
AccessibilityNodeInfofor the view corresponding to the given
This method is invoked by Android's accessibility system when Android needs accessibility info for a given view.
View.NO_ID is requested, accessibility node info is
returned for our
rootAccessibilityView. Otherwise, Flutter's semantics tree,
flutterSemanticsTree, is searched for a
SemanticsNode with the
virtualViewId. If no such
SemanticsNode is found, then this method
returns null. If the desired
SemanticsNode is found, then an
AccessibilityNodeInfo is obtained from the
rootAccessibilityView, filled with
appropriate info, and then returned.
Depending on the type of Flutter
SemanticsNode that is requested, the returned
AccessibilityNodeInfo pretends that the
SemanticsNode in question comes from a
specialize Android view, e.g.,
Flag#IS_TEXT_FIELD maps to
Flag#IS_BUTTON maps to
Flag#IS_IMAGE maps to
android.widget.ImageView. In the case that no specialized
view applies, the returned
AccessibilityNodeInfo pretends that it represents a
public boolean performAction(int virtualViewId, int accessibilityAction, @Nullable Bundle arguments)
virtualViewIdto carry out the desired
accessibilityAction, perhaps configured by additional
This method is invoked by Android's accessibility system. This method returns true if the
SemanticsNode was found and was capable of performing the desired action, false
In a traditional Android app, the given view ID refers to a
View within an Android
View hierarchy. Flutter does not have an Android
View hierarchy, therefore the
given view ID is a
virtualViewId that refers to a
SemanticsNode within a
Flutter app. The given arguments of this method are forwarded from Android to Flutter.
public AccessibilityNodeInfo findFocus(int focus)
This method is invoked by Android's accessibility system.
Flutter does not have an Android
View hierarchy. Therefore, Flutter conceptually
handles this request by searching its semantics tree for the given
flutterSemanticsTree. In practice, this
AccessibilityBridge always caches
Therefore, no searching is necessary. This method directly inspects the given
type to return one of the cached nodes, null if the cached node is null, or null if a different
focus type is requested.
public boolean onAccessibilityHoverEvent(MotionEvent event)
public void reset()
public boolean externalViewRequestSendAccessibilityEvent(View embeddedView, View eventOrigin, AccessibilityEvent event)
ViewParent.requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent)to the accessibility bridge.
This is used by embedded platform views to propagate accessibility events from their view hierarchy to the accessibility bridge.
As the embedded view doesn't have to be the only View in the embedded hierarchy (it can have child views) and the event might have been originated from any view in this hierarchy, this method gets both a reference to the embedded platform view, and a reference to the view from its hierarchy that sent the event.
embeddedView- the embedded platform view for which the event is delegated
eventOrigin- the view in the embedded view's hierarchy that sent the event.