Package io.flutter.view

# Interface TextureRegistry.SurfaceProducer.Callback

Enclosing interface:
  `TextureRegistry.SurfaceProducer`

public static interface TextureRegistry.SurfaceProducer.Callback
Callback invoked by `TextureRegistry.SurfaceProducer.setCallback(Callback)`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default void`
  `onSurfaceAvailable()`
  Invoked when an Android application is resumed after `onSurfaceDestroyed()`.
  `default void`
  `onSurfaceCleanup()`
  Invoked when a `Surface` returned by `TextureRegistry.SurfaceProducer.getSurface()` is about to become invalid.
  `default void`
  `onSurfaceCreated()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Override and use `onSurfaceAvailable()` instead.
  `default void`
  `onSurfaceDestroyed()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Override and use `onSurfaceCleanup()` instead.

- ## Method Details

  - ### onSurfaceCreated

    @Deprecated(since="Flutter 3.27", forRemoval=true) default void onSurfaceCreated()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Override and use `onSurfaceAvailable()` instead.
    An alias for `onSurfaceAvailable()` with a less accurate name.

  - ### onSurfaceAvailable

    default void onSurfaceAvailable()
    Invoked when an Android application is resumed after `onSurfaceDestroyed()`.

    When this method is overridden, `onSurfaceCreated()` is not called.

    Applications should now call `TextureRegistry.SurfaceProducer.getSurface()` to get a new `Surface`, as the previous one was destroyed and released as a result of a low memory event from the Android OS.

         void example(SurfaceProducer producer) {
           producer.setCallback(new SurfaceProducer.Callback() {
             @override
             public void onSurfaceAvailable() {
               Surface surface = producer.getSurface();
               redrawOrUse(surface);
             }

             // ...
           });
         }

  - ### onSurfaceDestroyed

    @Deprecated(since="Flutter 3.28", forRemoval=true) default void onSurfaceDestroyed()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Override and use `onSurfaceCleanup()` instead.
    An alias for `onSurfaceCleanup()` with a less accurate name.

  - ### onSurfaceCleanup

    default void onSurfaceCleanup()
    Invoked when a `Surface` returned by `TextureRegistry.SurfaceProducer.getSurface()` is about to become invalid.

    When this method is overridden, `onSurfaceDestroyed()` is not called.

    In a low memory environment, the Android OS will signal to Flutter to release resources, such as surfaces, that are not currently in use, such as when the application is in the background, and this method is subsequently called to notify a plugin author to stop using or rendering to the last surface.

    Use `onSurfaceAvailable()` to be notified to resume rendering.

         void example(SurfaceProducer producer) {
           producer.setCallback(new SurfaceProducer.Callback() {
             @override
             public void onSurfaceCleanup() {
               // Store information about the last frame, if necessary.
               // Potentially release other dependent resources.
             }

             // ...
           });
         }