Package io.flutter.plugin.platform

# Class PlatformViewsController2

java.lang.Object
io.flutter.plugin.platform.PlatformViewsController2

All Implemented Interfaces:
  `PlatformViewsAccessibilityDelegate`

public class PlatformViewsController2 extends Object implements PlatformViewsAccessibilityDelegate
Manages platform views.

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
  Constructor
  Description
  `PlatformViewsController2()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `applyTransactions()`
  `void`
  `attach(Context context, DartExecutor dartExecutor)`
  Attaches this platform views controller to its input and output channels.
  `void`
  `attachAccessibilityBridge(AccessibilityBridge accessibilityBridge)`
  Attaches an accessibility bridge for this platform views accessibility delegate.
  `void`
  `attachTextInputPlugin(TextInputPlugin textInputPlugin)`
  Attaches this controller to a text input plugin.
  `void`
  `attachToFlutterRenderer(FlutterRenderer flutterRenderer)`
  `void`
  `attachToView(FlutterView newFlutterView)`
  Attaches the controller to a `FlutterView`.
  `PlatformView`
  `createFlutterPlatformView(PlatformViewCreationRequest request)`
  `FlutterOverlaySurface`
  `createOverlaySurface()`
  `SurfaceControl.Transaction`
  `createTransaction()`
  `void`
  `destroyOverlaySurface()`
  `void`
  `detach()`
  Detaches this platform views controller.
  `void`
  `detachAccessibilityBridge()`
  Detaches the current accessibility bridge.
  `void`
  `detachFromView()`
  Detaches the controller from `FlutterView`.
  `void`
  `detachTextInputPlugin()`
  Detaches this controller from the currently attached text input plugin.
  `void`
  `disposePlatformView(int viewId)`
  Disposes a single
  `View`
  `getPlatformViewById(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.
  `PlatformViewRegistry`
  `getRegistry()`
  `void`
  `hideOverlaySurface()`
  `void`
  `hidePlatformView(int viewId)`
  `boolean`
  `isHcppEnabled()`
  `void`
  `onDetachedFromJNI()`
  Invoked when the `FlutterEngine` that owns this `PlatformViewsController` detaches from JNI.
  `void`
  `onDisplayPlatformView(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.
  `void`
  `onEndFrame()`
  `void`
  `onPreEngineRestart()`
  `void`
  `setFlutterJNI(FlutterJNI flutterJNI)`
  Whether the SurfaceControl swapchain mode is enabled.
  `void`
  `setRegistry(PlatformViewRegistry registry)`
  `void`
  `showOverlaySurface()`
  `void`
  `swapTransactions()`
  `MotionEvent`
  `toMotionEvent(float density, PlatformViewTouch touch)`
  `boolean`
  `usesVirtualDisplay(int id)`
  Returns true if the platform view uses virtual displays.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PlatformViewsController2

    public PlatformViewsController2()

- ## Method Details

  - ### setRegistry

    public void setRegistry(@NonNull PlatformViewRegistry registry)

  - ### setFlutterJNI

    public void setFlutterJNI(FlutterJNI flutterJNI)
    Whether the SurfaceControl swapchain mode is enabled.

  - ### usesVirtualDisplay

    public boolean usesVirtualDisplay(int id)
    Description copied from interface: `PlatformViewsAccessibilityDelegate`
    Returns true if the platform view uses virtual displays.
    Specified by:
      `usesVirtualDisplay` in interface `PlatformViewsAccessibilityDelegate`

  - ### createFlutterPlatformView

    public PlatformView createFlutterPlatformView(@NonNull PlatformViewCreationRequest request)

  - ### toMotionEvent

    @VisibleForTesting public MotionEvent toMotionEvent(float density, PlatformViewTouch touch)

  - ### attach

    public void attach(@Nullable Context context, @NonNull DartExecutor dartExecutor)
    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

    public void attachToView(@NonNull FlutterView newFlutterView)
    Attaches the controller to a `FlutterView`.

    When `FlutterFragment` is used, this method is called after the device rotates since the FlutterView is recreated after a rotation.

  - ### detachFromView

    public void detachFromView()
    Detaches the controller from `FlutterView`.

    When `FlutterFragment` is 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

    public void attachAccessibilityBridge(@NonNull AccessibilityBridge accessibilityBridge)
    Description copied from interface: `PlatformViewsAccessibilityDelegate`
    Attaches 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:
      `attachAccessibilityBridge` in interface `PlatformViewsAccessibilityDelegate`

  - ### detachAccessibilityBridge

    public void detachAccessibilityBridge()
    Description copied from interface: `PlatformViewsAccessibilityDelegate`
    Detaches 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:
      `detachAccessibilityBridge` in interface `PlatformViewsAccessibilityDelegate`

  - ### attachTextInputPlugin

    public void attachTextInputPlugin(@NonNull TextInputPlugin textInputPlugin)
    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

    public PlatformViewRegistry getRegistry()

  - ### onDetachedFromJNI

    public void onDetachedFromJNI()
    Invoked when the `FlutterEngine` that owns this `PlatformViewsController` detaches from JNI.

  - ### onPreEngineRestart

    public void onPreEngineRestart()

  - ### getPlatformViewById

    @Nullable public View getPlatformViewById(int viewId)
    Description copied from interface: `PlatformViewsAccessibilityDelegate`
    Returns the root of the view hierarchy for the platform view with the requested id, or null if there is no corresponding view.
    Specified by:
      `getPlatformViewById` in interface `PlatformViewsAccessibilityDelegate`

  - ### disposePlatformView

    @VisibleForTesting public void disposePlatformView(int viewId)
    Disposes a single
    Parameters:
      `viewId` - the PlatformView ID.

  - ### attachToFlutterRenderer

    public void attachToFlutterRenderer(@NonNull FlutterRenderer flutterRenderer)

  - ### 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 to `FlutterView`.
      `y` - The top position relative to `FlutterView`.
      `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.

  - ### hidePlatformView

    public void hidePlatformView(int viewId)

  - ### onEndFrame

    @RequiresApi(34) public void onEndFrame()

  - ### swapTransactions

    public void swapTransactions()

  - ### createTransaction

    @RequiresApi(34) public SurfaceControl.Transaction createTransaction()

  - ### applyTransactions

    @RequiresApi(34) public void applyTransactions()

  - ### createOverlaySurface

    @RequiresApi(34) public FlutterOverlaySurface createOverlaySurface()

  - ### destroyOverlaySurface

    public void destroyOverlaySurface()

  - ### showOverlaySurface

    @RequiresApi(34) public void showOverlaySurface()

  - ### hideOverlaySurface

    @RequiresApi(34) public void hideOverlaySurface()

  - ### isHcppEnabled

    public boolean isHcppEnabled()