Class PlatformViewsController2
- All Implemented Interfaces:
PlatformViewsAccessibilityDelegate
Each FlutterEngine has a single platform views controller.
A platform views controller can be attached to at most one Flutter view.
[PlatformViewsController2] is intentionally a different class from [PlatformViewsController] in
order to separate out the complexity of the first 3 platform view implementations (Virtual
Display, Texture Layer, and Hybrid Composition). From the 4th platform view implementation,
Hybrid Composition++.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidattach(Context context, DartExecutor dartExecutor) Attaches this platform views controller to its input and output channels.voidattachAccessibilityBridge(AccessibilityBridge accessibilityBridge) Attaches an accessibility bridge for this platform views accessibility delegate.voidattachTextInputPlugin(TextInputPlugin textInputPlugin) Attaches this controller to a text input plugin.voidattachToFlutterRenderer(FlutterRenderer flutterRenderer) voidattachToView(FlutterView newFlutterView) Attaches the controller to aFlutterView.voidvoiddetach()Detaches this platform views controller.voidDetaches the current accessibility bridge.voidDetaches the controller fromFlutterView.voidDetaches this controller from the currently attached text input plugin.voiddisposePlatformView(int viewId) Disposes a singlegetPlatformViewById(int viewId) Returns the root of the view hierarchy for the platform view with the requested id, or null if there is no corresponding view.voidvoidInvoked when theFlutterEnginethat owns thisPlatformViewsControllerdetaches from JNI.voidonDisplayPlatformView(int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, FlutterMutatorsStack mutatorsStack) Called when a platform view id displayed in the current frame.voidvoidvoidsetFlutterJNI(FlutterJNI flutterJNI) Whether the SurfaceControl swapchain mode is enabled.voidsetRegistry(PlatformViewRegistry registry) voidvoidtoMotionEvent(float density, PlatformViewsChannel2.PlatformViewTouch touch) booleanusesVirtualDisplay(int id) Returns true if the platform view uses virtual displays.
-
Constructor Details
-
PlatformViewsController2
public PlatformViewsController2()
-
-
Method Details
-
setRegistry
-
setFlutterJNI
Whether the SurfaceControl swapchain mode is enabled. -
usesVirtualDisplay
public boolean usesVirtualDisplay(int id) Description copied from interface:PlatformViewsAccessibilityDelegateReturns true if the platform view uses virtual displays.- Specified by:
usesVirtualDisplayin interfacePlatformViewsAccessibilityDelegate
-
createFlutterPlatformView
public PlatformView createFlutterPlatformView(@NonNull PlatformViewsChannel2.PlatformViewCreationRequest request) -
toMotionEvent
@VisibleForTesting public MotionEvent toMotionEvent(float density, PlatformViewsChannel2.PlatformViewTouch touch) -
attach
Attaches this platform views controller to its input and output channels.- Parameters:
context- The base context that will be passed to embedded views created by this controller. This should be the context of the Activity hosting the Flutter application.dartExecutor- The dart execution context, which is used to set up a system channel.
-
detach
@UiThread public void detach()Detaches this platform views controller.This is typically called when a Flutter applications moves to run in the background, or is destroyed. After calling this the platform views controller will no longer listen to it's previous messenger, and will not maintain references to the texture registry, context, and messenger passed to the previous attach call.
-
attachToView
Attaches the controller to aFlutterView.When
FlutterFragmentis used, this method is called after the device rotates since the FlutterView is recreated after a rotation. -
detachFromView
public void detachFromView()Detaches the controller fromFlutterView.When
FlutterFragmentis used, this method is called when the device rotates since the FlutterView is detached from the fragment. The next time the fragment needs to be displayed, a new Flutter view is created, so attachToView is called again. -
attachAccessibilityBridge
Description copied from interface:PlatformViewsAccessibilityDelegateAttaches an accessibility bridge for this platform views accessibility delegate.Accessibility events originating in platform views belonging to this delegate will be delegated to this accessibility bridge.
- Specified by:
attachAccessibilityBridgein interfacePlatformViewsAccessibilityDelegate
-
detachAccessibilityBridge
public void detachAccessibilityBridge()Description copied from interface:PlatformViewsAccessibilityDelegateDetaches the current accessibility bridge.Any accessibility events sent by platform views belonging to this delegate will be ignored until a new accessibility bridge is attached.
- Specified by:
detachAccessibilityBridgein interfacePlatformViewsAccessibilityDelegate
-
attachTextInputPlugin
Attaches this controller to a text input plugin.While a text input plugin is available, the platform views controller interacts with it to facilitate delegation of text input connections to platform views.
A platform views controller should be attached to a text input plugin whenever it is possible for the Flutter framework to receive text input.
-
detachTextInputPlugin
public void detachTextInputPlugin()Detaches this controller from the currently attached text input plugin. -
getRegistry
-
onDetachedFromJNI
public void onDetachedFromJNI()Invoked when theFlutterEnginethat owns thisPlatformViewsControllerdetaches from JNI. -
onPreEngineRestart
public void onPreEngineRestart() -
getPlatformViewById
Description copied from interface:PlatformViewsAccessibilityDelegateReturns the root of the view hierarchy for the platform view with the requested id, or null if there is no corresponding view.- Specified by:
getPlatformViewByIdin interfacePlatformViewsAccessibilityDelegate
-
disposePlatformView
@VisibleForTesting public void disposePlatformView(int viewId) Disposes a single- Parameters:
viewId- the PlatformView ID.
-
attachToFlutterRenderer
-
onDisplayPlatformView
public void onDisplayPlatformView(int viewId, int x, int y, int width, int height, int viewWidth, int viewHeight, @NonNull FlutterMutatorsStack mutatorsStack) Called when a platform view id displayed in the current frame.- Parameters:
viewId- The ID of the platform view.x- The left position relative toFlutterView.y- The top position relative toFlutterView.width- The width of the platform view.height- The height of the platform view.viewWidth- The original width of the platform view before applying the mutator stack.viewHeight- The original height of the platform view before applying the mutator stack.mutatorsStack- The mutator stack. This member is not intended for public use, and is only visible for testing.
-
onEndFrame
@RequiresApi(34) public void onEndFrame() -
swapTransactions
public void swapTransactions() -
createTransaction
-
applyTransactions
@RequiresApi(34) public void applyTransactions() -
createOverlaySurface
-
destroyOverlaySurface
public void destroyOverlaySurface() -
showOverlaySurface
@RequiresApi(34) public void showOverlaySurface() -
hideOverlaySurface
@RequiresApi(34) public void hideOverlaySurface()
-