Class FlutterSurfaceView

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

public class FlutterSurfaceView extends SurfaceView implements RenderSurface
Paints a Flutter UI on a Surface.

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

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

A FlutterSurfaceView 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 FlutterSurfaceView internally.

  • Constructor Details

    • FlutterSurfaceView

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

      public FlutterSurfaceView(@NonNull Context context, boolean renderTransparently)
      Constructs a FlutterSurfaceView programmatically, without any XML attributes, and with control over whether or not this FlutterSurfaceView renders with transparency.
    • FlutterSurfaceView

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

    • gatherTransparentRegion

      public boolean gatherTransparentRegion(Region region)
      Overrides:
      gatherTransparentRegion in class SurfaceView
    • 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 FlutterSurfaceView when it wants to begin rendering a Flutter UI to this FlutterSurfaceView.

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

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

      Specified by:
      attachToRenderer in interface RenderSurface
    • detachFromRenderer

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

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

      Specified by:
      detachFromRenderer in interface RenderSurface
    • pause

      public void pause()
      Invoked by the owner of this FlutterSurfaceView when it should pause rendering Flutter UI to this FlutterSurfaceView.
      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