FFplayDesktopTexture class
Flutter Texture-backed native surface for FFplay video output.
On Linux and Windows, FFplay renders frames with SDL2 software renderer.
After each video_refresh the C++ platform plugin receives decoded pixels
through ffplay_kit_register_frame_callback, copies them into a
FlutterDesktopPixelBuffer, and signals Flutter to repaint via
MarkTextureFrameAvailable. The Texture widget composites the
current frame into the widget tree.
On iOS and macOS, the same wrapper represents the Apple native Flutter texture/CVPixelBuffer path. The public toWidget contract is shared, but only Linux and Windows use the pixel-buffer callback implementation described above.
Typical usage
// Before starting playback:
_texture = await FFplayDesktopTexture.create();
final session = await FFplayKit.executeAsync('-i "$path"');
// Display in the widget tree:
_texture?.toWidget() // use inside AspectRatio / SizedBox
// When done:
await _texture?.release();
_texture = null;
On Android, create returns null and all other methods are no-ops.
API symmetry with FFplayAndroidSurface
Both classes expose create, bindToFFplay, toWidget, and release.
On desktop, bindToFFplay is a no-op because the C++ plugin registers the
frame callback automatically when create is called.
Properties
Methods
-
bindToFFplay(
) → void -
No-op on desktop — frame callback is wired by C++ plugin when
createis called. Provided for API symmetry withFFplayAndroidSurfaceso callers can write platform-agnostic setup code. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
release(
) → Future< void> -
Releases native pixel-buffer texture and stops frame delivery.
The native plugin calls
ffplay_set_frame_callback(null, null)before unregistering the texture withTextureRegistrar. After calling this, discard the FFplayDesktopTexture instance. -
toString(
) → String -
A string representation of this object.
inherited
-
toWidget(
) → Widget - Returns Widget that displays this texture in Flutter widget tree. Forces widget recreation when textureId changes OR playback state changes. (ValueKey combines both textureId and playback context for unique widgets)
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
) → Future< FFplayDesktopTexture?> - Allocates Flutter Texture backed by native pixel buffer. Internally the native plugin: