Class FlutterTextureView

java.lang.Object
android.view.View
android.view.TextureView
io.flutter.embedding.android.FlutterTextureView
All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, RenderSurface

public class FlutterTextureView extends TextureView implements RenderSurface
Paints a Flutter UI on a SurfaceTexture.

To begin rendering a Flutter UI, the owner of this FlutterTextureView must invoke attachToRenderer(FlutterRenderer) with the desired FlutterRenderer.

To stop rendering a Flutter UI, the owner of this FlutterTextureView must invoke detachFromRenderer().

A FlutterTextureView is intended for situations where a developer needs to render a Flutter UI, but does not require any keyboard input, gesture input, accessibility integrations or any other interactivity beyond rendering. If standard interactivity is desired, consider using a FlutterView which provides all of these behaviors and utilizes a FlutterTextureView internally.

  • Constructor Details

    • FlutterTextureView

      public FlutterTextureView(@NonNull Context context)
      Constructs a FlutterTextureView programmatically, without any XML attributes.
    • FlutterTextureView

      public FlutterTextureView(@NonNull Context context, @Nullable AttributeSet attrs)
      Constructs a FlutterTextureView in an XML-inflation-compliant manner.
  • Method Details

    • getAttachedRenderer

      @Nullable public FlutterRenderer getAttachedRenderer()
      Description copied from interface: RenderSurface
      Returns the FlutterRenderer that is attached to this RenderSurface, or null if no FlutterRenderer is currently attached.
      Specified by:
      getAttachedRenderer in interface RenderSurface
    • attachToRenderer

      public void attachToRenderer(@NonNull FlutterRenderer flutterRenderer)
      Invoked by the owner of this FlutterTextureView when it wants to begin rendering a Flutter UI to this FlutterTextureView.

      If an Android SurfaceTexture is available, this method will give that SurfaceTexture to the given FlutterRenderer to begin rendering Flutter's UI to this FlutterTextureView.

      If no Android SurfaceTexture is available yet, this FlutterTextureView will wait until a SurfaceTexture becomes available and then give that SurfaceTexture to the given FlutterRenderer to begin rendering Flutter's UI to this FlutterTextureView.

      Specified by:
      attachToRenderer in interface RenderSurface
    • detachFromRenderer

      public void detachFromRenderer()
      Invoked by the owner of this FlutterTextureView when it no longer wants to render a Flutter UI to this FlutterTextureView.

      This method will cease any on-going rendering from Flutter to this FlutterTextureView.

      Specified by:
      detachFromRenderer in interface RenderSurface
    • pause

      public void pause()
      Invoked by the owner of this FlutterTextureView when it should pause rendering Flutter UI to this FlutterTextureView.
      Specified by:
      pause in interface RenderSurface
    • resume

      public void resume()
      Description copied from interface: RenderSurface
      Instructs this RenderSurface to resume forwarding Surface notifications to the FlutterRenderer that was previously connected with RenderSurface.attachToRenderer(FlutterRenderer).
      Specified by:
      resume in interface RenderSurface
    • setRenderSurface

      @VisibleForTesting public void setRenderSurface(Surface renderSurface)
      Manually set the render surface for this view.

      This should only be used for testing purposes.