flutter_wgpu_texture 0.2.1 copy "flutter_wgpu_texture: ^0.2.1" to clipboard
flutter_wgpu_texture: ^0.2.1 copied to clipboard

Flutter plugin for building 2D and 3D wgpu apps on desktop and web.

flutter_wgpu_texture #

screenshot-wgpu-texture

Flutter plugin for building 2D and 3D wgpu apps in Flutter. Renders GPU content on macOS, Windows, Linux, and web via Rust-powered native and web backends.

Platform Supported Backend
macOS Metal
Windows D3D12
Linux Vulkan (via dma-buf)
Web WebGPU (Chrome 120+), WebGL2 fallback (Firefox, Safari, Brave)
Android ✗ Soon
iOS ✗ Soon

Installation #

dependencies:
  flutter_wgpu_texture:
    ^0.2.0

Requirements:

  • Flutter desktop toolchain
  • Rust toolchain (rustup)
  • macOS: Xcode command line tools
  • Windows: Visual Studio C++ build tools
  • Linux: Vulkan or EGL drivers
  • Web: any modern browser (Chrome 120+ for WebGPU, or any browser with WebGL2 support)

Usage #

final controller = FlutterWgpuTextureController(sceneType: 'cube');

@override
Widget build(BuildContext context) {
  return FlutterWgpuTexture(controller: controller);
}

Control the renderer at runtime:

await controller.setCubeColor(const Color(0xFFFFD400));
await controller.setBackgroundColor(const Color(0xFF1B5CFF));
await controller.setFloatParam('rotation_speed', 0.8);
await controller.stopAnimation();
await controller.invokeRustCommand('reset_scene');

See the API reference for the full controller API.

Examples #

Example Description
spinning_cube Rotating 3D cube with color controls
particles Particle scene with size and motion controls
shader_playground Live WGSL shader editor with uniform sliders
custom_scene Animated gradient — custom scene outside the plugin
cd example          # spinning_cube (canonical pub.dev example)
flutter pub get
flutter run -d macos  # or windows / linux / chrome

Custom scenes #

You can implement your own GPU scene in Rust without forking the plugin. The plugin's renderer is split into two crates:

  • flutter_wgpu_texture_core — the Scene trait, SceneRenderArgs, and a global scene registry (published to crates.io).
  • flutter_wgpu_texture — the FRB API, C exports, and built-in scenes.

Add a Rust workspace to your app that links both the engine and your scene crate into a single replacement dylib. Your scene self-registers via #[ctor::ctor] at load time, and Dart selects it with sceneType: 'my_scene'.

See doc/custom_scene.md for the step-by-step guide and example/custom_scene/ for a complete reference implementation (animated gradient with runtime colour controls).

Architecture #

Built on flutter_rust_bridge and native_toolchain_rust. The Dart controller coordinates a Rust/wgpu renderer via FRB FFI; the renderer writes directly into a shared Metal / D3D12 / DMA-BUF surface that Flutter composites as a texture.