/prometheus-flutter-skills:flutter-rust-ffifrom prometheus-flutter-skills
Flutter + Rust FFI architecture for Prometheus AGS mobile and desktop apps using flutter_rust_bridge v2 and Riverpod 2.6. Covers the gen_ui_core shared Rust crate, bridge code generation, Riverpod provider wiring to Rust async functions, FFI thread safety, and bidirectional embedding patterns (React 19 embedding Flutter, Flutter embedding React via WebView). Use when building any Prometheus hybrid mobile app.
Ships in prometheus-flutter-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
All Prometheus AGS Flutter apps share a Rust core crate (gen_ui_core) via
flutter_rust_bridge v2. The Rust crate handles: inference calls, MCP protocol,
SurrealDB queries, network I/O, and CPU-intensive work. Flutter handles UI only.
gen_ui_core/ ← shared Rust crate (workspace member)
src/
lib.rs ← re-exports all bridge APIs
inference.rs ← candle-vllm calls, streaming
mcp.rs ← MCP client over reqwest/SSE
memory.rs ← SurrealDB / surreal-memory-server client
agent.rs ← UAR job submission + result streaming
flutter_app/
lib/
main.dart
src/
bridge/ ← generated by flutter_rust_bridge (do not edit)
features/
inference/
inference_provider.dart ← Riverpod AsyncNotifier wrapping Rust call
inference_screen.dart
shared/
providers/ ← app-wide Riverpod providers
In pubspec.yaml:
dependencies:
flutter_rust_bridge: ^2.0.0
riverpod: ^2.6.0
go_router: ^14.0.0
dev_dependencies:
flutter_rust_bridge_codegen: ^2.0.0
build_runner: ^2.4.0
Generate bridge code after changing Rust API:
flutter_rust_bridge_codegen generate
Only pub functions in gen_ui_core/src/api/ are exposed to Dart. Use #[frb]
attribute for types that need special handling.
// gen_ui_core/src/api/inference.rs
use flutter_rust_bridge::frb;
#[frb(sync)] // sync variant — use sparingly, blocks Dart isolate
pub fn get_model_list() -> Vec<String> {
vec!["qwen2.5-7b".to_string(), "mistral-7b".to_string()]
}
// Async (preferred) — runs on Rust's tokio thread pool
pub async fn run_inference(prompt: String, model: String) -> anyhow::Result<String> {
let client = crate::inference::InferenceClient::global()?;
client.complete(&prompt, &model).await
}
// Streaming — uses DartFnFuture for callback
pub async fn stream_inference(
prompt: String,
model: String,
on_token: impl Fn(String) -> DartFnFuture<()>,
) -> anyhow::Result<()> {
let client = crate::inference::InferenceClient::global()?;
client.stream(&prompt, &model, |token| async { on_token(token).await }).await
}
// lib/src/features/inference/inference_provider.dart
import 'package:riverpod_annotation/riverpod_annotation.dart';
import '../../../bridge/gen_ui_core.dart'; // generated bridge
part 'inference_provider.g.dart';
@riverpod
class InferenceNotifier extends _$InferenceNotifier {
@override
FutureOr<String?> build() => null;
Future<void> complete(String prompt, String model) async {
state = const AsyncLoading();
state = await AsyncValue.guard(() => runInference(prompt: prompt, model: model));
}
}
// For streaming — use StreamProvider
@riverpod
Stream<String> inferenceStream(InferenceStreamRef ref, String prompt, String model) async* {
await for (final token in streamInferenceTokens(prompt: prompt, model: model)) {
yield token;
}
}
DartFnFutureflutter_rust_bridge typesasync functions run on the Dart isolate's tokio runtime, not the UI threadtokio::task::spawn_blocking inside the Rust functionFor web targets where a Prometheus React 19 app needs Flutter UI islands:
// In the React 19 app
import { useEffect, useRef } from 'react'
export function FlutterWidget({ src }: { src: string }) {
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
if (!ref.current) return
// Flutter web embedding via _flutter.loader
window._flutter?.loader?.loadEntrypoint({
entrypointUrl: src,
onEntrypointLoaded: async (engineInitializer) => {
const appRunner = await engineInitializer.initializeEngine({
hostElement: ref.current!,
})
await appRunner.runApp()
},
})
}, [src])
return <div ref={ref} style={{ width: '100%', height: '100%' }} />
}
For native Flutter apps that need a React 19 micro-frontend:
import 'package:webview_flutter/webview_flutter.dart';
class ReactMicroFrontend extends StatelessWidget {
final String url;
const ReactMicroFrontend({required this.url, super.key});
@override
Widget build(BuildContext context) {
final controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..loadRequest(Uri.parse(url));
// Expose Rust FFI to the embedded React app via JS channel
controller.addJavaScriptChannel(
'RustBridge',
onMessageReceived: (msg) async {
final result = await callRustFromJs(msg.message);
controller.runJavaScript('window.rustResponse("$result")');
},
);
return WebViewWidget(controller: controller);
}
}
// lib/src/router.dart
import 'package:go_router/go_router.dart';
final router = GoRouter(
routes: [
GoRoute(path: '/', builder: (ctx, state) => const HomeScreen()),
GoRoute(path: '/inference', builder: (ctx, state) => const InferenceScreen()),
GoRoute(
path: '/entity/:id',
builder: (ctx, state) => EntityDetailScreen(id: state.pathParameters['id']!),
),
],
);
setState() for server data — use Riverpod AsyncNotifierProvider() legacy syntax — use @riverpod annotation#[frb(sync)] only for trivial ops)dynamic type — use explicit types or Object?What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub prometheus-ags/prometheus-skill-system --plugin prometheus-flutter-skills2 plugins in one repository ship this exact skill · first indexed Nov 27, 2026