io.flutter.plugin.platform

## Class PlatformViewsController

- java.lang.Object
- - io.flutter.plugin.platform.PlatformViewsController

- All Implemented Interfaces:
    PlatformViewsAccessibilityDelegate

      public class PlatformViewsController
      extends Object
      implements PlatformViewsAccessibilityDelegate

  Manages platform views.

  Each `FlutterPluginRegistry` has a single platform views controller. A platform views controller can be attached to at most one Flutter view.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PlatformViewsController()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `attach(Context context, TextureRegistry textureRegistry, 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(View flutterView)` This `PlatformViewsController` and its `FlutterEngine` is now attached to an Android `View` that renders a Flutter UI.
    `boolean` | `checkInputConnectionProxy(View view)` Returns true if Flutter should perform input connection proxying for the view.
    `FlutterOverlaySurface` | `createOverlaySurface()` Creates an overlay surface while the Flutter view is rendered by `FlutterImageView`.
    `FlutterOverlaySurface` | `createOverlaySurface(FlutterImageView imageView)` Creates and tracks the overlay surface.
    `void` | `destroyOverlaySurfaces()` Destroys the overlay surfaces and removes them from the view hierarchy.
    `void` | `detach()` Detaches this platform views controller.
    `void` | `detachAccessibiltyBridge()` Detaches the current accessibility bridge.
    `void` | `detachFromView()` This `PlatformViewController` and its `FlutterEngine` are no longer attached to an Android `View` that renders a Flutter UI.
    `void` | `detachTextInputPlugin()` Detaches this controller from the currently attached text input plugin.
    `View` | `getPlatformViewById(Integer id)` 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` | `onAttachedToJNI()` Invoked when the `FlutterEngine` that owns this `PlatformViewsController` attaches to JNI.
    `void` | `onBeginFrame()`
    `void` | `onDetachedFromJNI()` Invoked when the `FlutterEngine` that owns this `PlatformViewsController` detaches from JNI.
    `void` | `onDisplayOverlaySurface(int id, int x, int y, int width, int height)` Called when an overlay surface is displayed in the current frame.
    `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()` Called by `FlutterJNI` when the Flutter frame was submitted.
    `void` | `onPreEngineRestart()`
    `MotionEvent` | `toMotionEvent(float density, PlatformViewsChannel.PlatformViewTouch touch, boolean usingVirtualDiplays)`
    `boolean` | `usesVirtualDisplay(Integer 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 Detail

    - #### PlatformViewsController

          public PlatformViewsController()

  - ### Method Detail

    - #### toMotionEvent

          public MotionEvent toMotionEvent(float density,
                                           PlatformViewsChannel.PlatformViewTouch touch,
                                           boolean usingVirtualDiplays)

    - #### attach

          public void attach(Context context,
                             TextureRegistry textureRegistry,
                             @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.
        `textureRegistry` - The texture registry which provides the output textures into which the embedded views will be rendered.
        `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
                                   View flutterView)

      This `PlatformViewsController` and its `FlutterEngine` is now attached to an Android `View` that renders a Flutter UI.

    - #### detachFromView

          public void detachFromView()

      This `PlatformViewController` and its `FlutterEngine` are no longer attached to an Android `View` that renders a Flutter UI.

      All platform views controlled by this `PlatformViewController` will be detached from the previously attached `View`.

    - #### attachAccessibilityBridge

          public void attachAccessibilityBridge(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`

    - #### detachAccessibiltyBridge

          public void detachAccessibiltyBridge()

      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:
        `detachAccessibiltyBridge` in interface `PlatformViewsAccessibilityDelegate`

    - #### attachTextInputPlugin

          public void attachTextInputPlugin(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.

    - #### checkInputConnectionProxy

          public boolean checkInputConnectionProxy(@Nullable
                                                   View view)

      Returns true if Flutter should perform input connection proxying for the view.

      If the view is a platform view managed by this platform views controller returns true. Else if the view was created in a platform view's VD, delegates the decision to the platform view's `View.checkInputConnectionProxy(View)` method. Else returns false.

    - #### getRegistry

          public PlatformViewRegistry getRegistry()

    - #### onAttachedToJNI

          public void onAttachedToJNI()

      Invoked when the `FlutterEngine` that owns this `PlatformViewsController` attaches to JNI.

    - #### onDetachedFromJNI

          public void onDetachedFromJNI()

      Invoked when the `FlutterEngine` that owns this `PlatformViewsController` detaches from JNI.

    - #### onPreEngineRestart

          public void onPreEngineRestart()

    - #### getPlatformViewById

          public View getPlatformViewById(Integer id)

      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`

    - #### usesVirtualDisplay

          public boolean usesVirtualDisplay(Integer id)

      Description copied from interface: `PlatformViewsAccessibilityDelegate`
      Returns true if the platform view uses virtual displays.
      Specified by:
        `usesVirtualDisplay` in interface `PlatformViewsAccessibilityDelegate`

    - #### attachToFlutterRenderer

          public void attachToFlutterRenderer(FlutterRenderer flutterRenderer)

    - #### onDisplayPlatformView

          public 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.
      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.

    - #### onDisplayOverlaySurface

          public void onDisplayOverlaySurface(int id,
                                              int x,
                                              int y,
                                              int width,
                                              int height)

      Called when an overlay surface is displayed in the current frame.
      Parameters:
        `id` - The ID of the surface.
        `x` - The left position relative to `FlutterView`.
        `y` - The top position relative to `FlutterView`.
        `width` - The width of the surface.
        `height` - The height of the surface.

    - #### onBeginFrame

          public void onBeginFrame()

    - #### onEndFrame

          public void onEndFrame()

      Called by `FlutterJNI` when the Flutter frame was submitted.

    - #### createOverlaySurface

          public FlutterOverlaySurface createOverlaySurface(@NonNull
                                                            FlutterImageView imageView)

      Creates and tracks the overlay surface.
      Parameters:
        `imageView` - The surface that displays the overlay.
      Returns:
        Wrapper object that provides the layer id and the surface.

    - #### createOverlaySurface

          public FlutterOverlaySurface createOverlaySurface()

      Creates an overlay surface while the Flutter view is rendered by `FlutterImageView`.

      This method is invoked by `FlutterJNI` only.

    - #### destroyOverlaySurfaces

          public void destroyOverlaySurfaces()

      Destroys the overlay surfaces and removes them from the view hierarchy.

      This method is used only internally by `FlutterJNI`.