核心包不含运行时,需按需另装引擎包如 flutter_edge_ai_litertlm 或 flutter_edge_ai_llama;除系统自带模型外,模型需单独下载安装;MediaPipe 引擎的 LLM Inference API 仅维护,新项目建议用 .litertlm。
flutter_edge_ai
DenisovAVMIT活跃维护让 Flutter 应用在手机、桌面和 Web 上直接跑 Gemma 等大模型,支持多模态、函数调用、向量嵌入、RAG 和语音,不用依赖云端。
On-device AI for Flutter — Gemma and other LLMs, multimodal, function calling, embeddings, RAG and speech on Android, iOS, Web, macOS, Windows and Linux.
flutter pub add flutter_edge_aiREADME 未说明具体显存或 GPU 型号要求;引擎覆盖 CPU、GPU 与 NPU,并支持 Android、iOS、Web、macOS、Windows、Linux 六端。
Flutter 端侧 AI 框架,在六端本地跑 LLM、多模态、RAG 与语音,无需服务器
让 Flutter 应用在手机、桌面和 Web 上直接跑 Gemma 等大模型,支持多模态、函数调用、向量嵌入、RAG 和语音,不用依赖云端。
核心能力
- 核心包只负责装模型和引擎注册,按需引入运行时包
- 支持 LiteRT-LM、llama.cpp、ONNX、MediaPipe 多种引擎
- 可直接调用系统自带模型如 Gemini Nano 与 Apple Foundation Models
- 内置端侧 RAG:嵌入、向量存储与 SQLite/Qdrant 后端
- 提供语音识别合成、Agent 技能与 Genkit 混合路由
容易踩的坑
- native-v0.19.0-aNative dylibs native-v0.19.0-a最新正式版2026-11-04 · 2026-11-04 11:47 UTC
Native libraries for
flutter_edge_ai_litertlmon LiteRT-LM v0.19.0.Pins: LiteRT-LM
771b06e1(v0.19.0; the tag later moved to83ce6067, which changes onlyPackage.swiftandREADME.md). LiteRTdcb657e8. C API 1.0. Qualcomm dispatch built against QAIRT 2.50.0. Intel NPU stack on OpenVINO 2026.4.1, from the LiteRT pin.Built from:
native/litertlm-0.19at37d1ec59(4688a11f, the branch tip, changes only a probe; macOS, iOS and Android locally with the official scripts from fresh clones, Android with NDK r29; Linux, Windows and the Linux arm64 Qualcomm dispatch in CI run 41812604940).Requires: a
flutter_edge_ai_litertlmrelease built on the C API 1.0 client. Releases up to 1.19.x keep usingnative-v0.18.0-h.Changes against native-v0.18.0-h
Patches applied by
patch_c_api.sh:- §1-§16: carried forward; several re-created against v0.19.0.
- §17: SentencePiece accepts a multi-byte NUL piece, on top of upstream's one-byte rule (Phi-4-mini q8).
- §18: upstream PR #4197, so §16 is exact on models that take embeddings.
- §19: Android links the OpenCL accelerator only (no Dawn).
- §20: no fused GPU sampler on Linux and Windows.
- §21: XNNPACK skips three SME2 branches on Apple.
- §22: the NPU executor saves every KV buffer of a conversation (LiteRT-LM #4355).
- §23: the turn-end record (
litert_lm_conversation_get_last_turn_end). A full context window is reported ascontext_full, also when no prefill chunk fits. Only the context-window checks report it; any otherRESOURCE_EXHAUSTED, such as a failed allocation, ends the turnfailed. A send refused before it starts (a NULL argument, a message that is not JSON) is reported asrefused(8) with its status code. A failed turn no longer leaves its benchmark turn open. - §24: a prefill after a rewind keeps the step of the tokens it reuses. Before, the history could be lost.
- §25: a new context clears LFM2's convolution state. Before, state carried from one conversation to the next.
Packaging:
- StreamProxy exports
stream_proxy_create_v1(the C API 1.0 accessor types),stream_proxy_destroy_v1(frees a proxy whose send was refused) andstream_proxy_free_string. A stream ends for the caller only at native's final chunk, and a native error on an earlier chunk is held until then. - Android:
libLiteRtOpenClAccelerator.soandlibLiteRtTopKOpenClSampler.soare no longer shipped; libLiteRtLm links them. - Linux and Windows: no TopK WebGPU sampler.
- The MediaTek dispatch adapter is not shipped (the MediaTek NPU is not supported in this release).
- The Gemma constraint provider (
libGemmaModelConstraintProvider) comes from the LiteRT-LM pin on every platform: upstream's d99b438f binary. Linux and Windows already took it from the pin; macOS, iOS and Android now do too. The interface it implements (constraint.h) is unchanged. On Linux it is the binary the §12 bridge's layout was measured on (x86_64fc4e17a9…, arm644685001b…).
Tested on
The device runs below used scratch builds of this release. The macOS, iOS and Android scratch builds carried the constraint provider of the v0.18.0 tag. So the tool-call and constrained-decoding results there were measured with the old provider: macOS CPU and Metal, Galaxy S25 Ultra (Adreno 830 and the SM8750 NPU), Pixel 11 (Tensor G6 NPU), Pixel 8a (Mali-G715). The next device campaign re-checks tool calls on those.
The release archives themselves were smoke-tested on macOS, CPU and Metal: turn ends, prefill room, rewinds, three conversations, tool calls, constrained decoding, determinism, deleting a conversation during another's reply. Linux arm64 (Docker, CPU) ran turn ends, prefill room and a tool call. Earlier scratch builds of this release were run on:
- macOS M-series: CPU and Metal.
- Linux arm64: CPU (Docker).
- Galaxy S25 Ultra: SM8750 Qualcomm NPU and Adreno 830.
- Pixel 11: Tensor G6 NPU and PowerVR GPU.
- Pixel 8a: Mali-G715.
- Windows Panther Lake: CPU, Arc B390 and Intel NPU.
- Wind
- native-onnx-genai-v0.17.0-aONNX Runtime GenAI 0.17.0 for Android (native-onnx-genai-v0.17.0-a)2026-11-02 · 2026-11-02 03:27 UTC
查看更新说明
ONNX Runtime GenAI 0.17.0 for Android arm64, built without telemetry, for
flutter_edge_ai_onnx. Itshook/build.dartfetches this zip at build time and checks its SHA-256.Why not Microsoft's AAR. The
libonnxruntime-genai.soin Microsoft's 0.17.0 Android AAR listslibmat.so(the 1DS telemetry SDK) inDT_NEEDED. Thatlibmat.sois 4 KB-aligned. Google Play rejects it for apps that target API 35 or later, and a device with 16 KB pages cannot load it.What this build is.
- Source: microsoft/onnxruntime-genai
v0.17.0, commit1d67be30e5b1ed0c264f6f41c598f85157e8288b. - Built against ONNX Runtime 1.27.0: headers and
libonnxruntime.sofrom Maven Centralcom.microsoft.onnxruntime:onnxruntime-android:1.27.0, SHA-256 checked. - CMake:
ENABLE_TELEMETRY=OFF, Release,arm64-v8a, Android API 27. - Toolchain: Android NDK r29 (29.0.14206865, clang 21.0.0).
- Script:
packages/flutter_edge_ai_onnx/native/build_genai_android.sh.
What was checked on this file.
DT_NEEDED:liblog.so,libm.so,libdl.so,libc.soonly.- Every PT_LOAD segment has
p_align0x4000, and the hook's own check (requireAndroidPageAlign) accepts it. - The library contains no
OneCollectorstring and no 1DS endpoint.
Asset.
File SHA-256 onnxruntime-genai-android-0.17.0-a.zip(containsjni/arm64-v8a/libonnxruntime-genai.so, the AAR's layout)fe491a77f3bac8e72ae45814394a705a1c8bbf3aa69e1fd97106d8d1ea6cef76The build is not byte-reproducible across machines: the NDK version, the build directory (in
__FILE__strings) and the zip entry times all change the bytes. The SHA-256 above is the pin inhook/build.dart.The
-asuffix follows this repository's convention for a build of an upstream release that is not upstream's own binary.The library is MIT-licensed (microsoft/onnxruntime-genai); ONNX Runtime, which it loads, is MIT-licensed (microsoft/onnxruntime).
Run on a device. Galaxy S25 Ultra (Android 16), through
flutter_edge_ai_onnxwith this library in the APK: Qwen2.5-0.5B-Instruct (ORT-GenAI) loads on the CPU, generates, stops mid-turn, answers a third turn in the same session and closes. - Source: microsoft/onnxruntime-genai
- native-v0.18.0-hNative dylibs native-v0.18.0-h2026-10-27 · 2026-10-27 11:52 UTC
查看更新说明
native-v0.18.0-gwith the Windows archive changed alone.Windows: both copies of
libLiteRtWebGpuAccelerator.dll(lib-prefixed and not) are Google's prebuilt from LiteRT-LM5f973f57(sha2562fb3583681ffb28d2fa8c08803445839e579a8e67417bde480415a4360e18ed0), which contains LiteRT #11120: on an Intel GPU the dp4a int8 fully-connected/convolution path is turned off. Gemma 4 12B on an Intel GPU under D3D12 returned no text for prompts under 512 tokens (LiteRT-LM #4083); it now answers.Performance, Gemma 4 12B on an Intel GPU: prefill takes about 45% longer, because the fixed path runs in fp16/fp32 instead of int8. Measured on Panther Lake (Core Ultra X7 358H, Arc B390):
-g-h12B, 25-token prompt empty text correct answer, first token 1.07 s 12B, 7271-token prefill (original file) 19.8 s 28.5–29.0 s 12B, 7271-token prefill ( prefill_1024build)21.4–22.7 s 31.3–32.2 s 12B decode 12.5–12.7 tok/s 13.0–13.1 tok/s Gemma 4 E2B GPU decode 62.1 tok/s 65.6–67.3 tok/s CPU and NPU do not load this library: Gemma 4 E2B on CPU/NPU, Intel's 12B on the NPU and EmbeddingGemma 2 (270m on CPU and
_Intel_PTLon the NPU: same similarities to three decimals, same load times) measured unchanged. Other GPU vendors on Windows were not measured.The accelerator imports nothing from
libLiteRt.dll; itswebgpu_dawn.dllimports resolve against the shipped Dawn, byte-identical at both upstream refs. The other 23 Windows files and the six other archives are byte-identical tonative-v0.18.0-g.Archive sha256 litertlm-windows_x86_64.tar.gz 9b550ad40c5ef33346596d21df9498217eb96662a7bd457272b6c5e6742d5d59GemmaModelConstraintProvider.xcframework.zip 23bd0dead9e6d01641eedc1a2dae3441bb381363b03319ab4ab028b60b94c9acLiteRtLmMetalAccelerator.xcframework.zip e7cc3c25d9e82ef72f44e47724192bf3e2ce3ce757fde50be8c0dd98a26a7427the six other archives unchanged from native-v0.18.0-gmacOS, Swift Package Manager: the two companion zips that
macos/flutter_edge_ai_litertlm/Package.swiftfetches are packaged for this tag from its macOS archive (the same bytes as-g's: same LC_UUID). TheirCFBundleVersionis now numeric (0.18.8), the tag is inDevFlutteredgeNativeTag, and the zips no longer depend on the packager's timezone.checksums_spm_macos.txtlists them. - native-v0.18.0-gNative dylibs native-v0.18.0-g2026-10-21 · 2026-10-21 11:35 UTC
查看更新说明
native-v0.18.0-fwith the Windows archive changed alone: the Intel NPU stack moves from OpenVINO 2026.3.1 to 2026.4.1, andopenvino_intel_npu_vm_runtime.dlljoins it (#702). Same pins as-f: LiteRT-LMb2f686e2(v0.18.0), LiteRT26895c9f, Qualcomm dispatch against QAIRT 2.50.0.What changed, per archive.
- Windows:
LiteRtDispatch.dll,LiteRtLm.dll,StreamProxy.dll, the five OpenVINO DLLs and the four TBB DLLs come from CI run 39573062034 (commit79649ded);openvino_intel_npu_vm_runtime.dllis new. The other twelve files are byte-identical to-f. - Android, iOS, iOS simulator, macOS, Linux x86_64, Linux arm64: the
-farchives, byte for byte (same sha256).
OpenVINO 2026.4.1.
patches/litert_openvino_2026_4_1.patchis upstream LiteRT991d15588a, applied on the pin until the pin contains it. The 2026.3 NPU plugin refuses Intel's Gemma 4 12B for Panther Lake: "Imported blob metadata version: 2.7 but the current version is: 2.6".openvino_intel_npu_vm_runtime.dllis loaded by the NPU plugin by name; Gemma 4 E2B and the 12B load without it, and I ship it because Intel's own kit does.Verified with the bytes in this Windows archive. Probe app on the public API (Flutter 3.47.4 profile build), and
litertlm_ffi_testwith the sha256 of all 25 archive DLLs in the built app equal to the archive's:Panther Lake (Core Ultra X7 358H) Lunar Lake (Core Ultra 7 258V) Gemma 4 E2B GPU / CPU / NPU 30.0 / 23.5 / 53.6 tok/s 24.6 / 22.0 / 54.4 tok/s Gemma 4 12B on the NPU (Intel's Panther Lake bundle, 16384 context) 13.0 tok/s — EmbeddingGemma 2 270m _Intel_PTLon the NPU768-d, load 0.9 s — EmbeddingGemma 2 270m on CPU, then an LLM ✅ ✅ litertlm_ffi_test, full file— 25 passed, 2 skipped (NPU vision and audio: no Windows bundle with those towers) litertlm_ffi_test --plain-name NPU— 3 passed, 2 skipped; engine_create0.9–1.0 s, 59.6 tok/s, greedy run1 == run2 - Windows:
- native-v0.18.0-fNative dylibs native-v0.18.0-f2026-10-18 · 2026-10-18 21:18 UTC
查看更新说明
native-v0.18.0-eplus four changes: the stream proxy takes its chunk accessors from Dart, Windows Intel NPU loads its model again, a stopped turn can be rewound in place, and the Android archive carries the Google Tensor NPU dispatch. Same pins as-e: LiteRT-LMb2f686e2(v0.18.0), LiteRT26895c9f, Qualcomm dispatch against QAIRT 2.50.0.What changed, per archive. Every file not listed here is byte-identical to
-e, Android'slibLiteRtDispatch_Qualcomm.soand Linux arm64's Qualcomm dispatch andlibcdsprpc.soshim included:- All seven archives:
libLiteRtLmandStreamProxy. - Windows:
LiteRtDispatch.dll, rebuilt from the pin. - Android:
libLiteRtDispatch_GoogleTensor.so, a new file.
stream_proxy_create2(#668, #453). The Dart client resolves the three stream-chunk accessors on thelibLiteRtLmit drives and passes them in, so the shim keeps no global state.stream_proxy_createis still exported, unchanged, for older Dart.Windows Intel NPU (
patch_c_api.sh§15, #679, LiteRT-LM #4023).- Since LiteRT-LM v0.17.0, a bundle with a
TF_LITE_AUXsection (every AOT NPU bundle) was loaded through a C runtime file descriptor. - Google's prebuilt
libLiteRt.dlllinks its own C runtime, so it cannot read that descriptor; on v0.18.0 the process ended with0xC0000409. - Windows now loads those sections from memory, as v0.16.0 did.
Rewind a stopped turn (
patch_c_api.sh§16, #682). New export:litert_lm_conversation_rewind_cancelled_turn. After a stopped generation, the conversation returns to its state before that turn, so earlier images and audio stay in context.Google Tensor NPU dispatch (#670, #686).
libLiteRtDispatch_GoogleTensor.sois built from LiteRT'slitert/vendors/google_tensor/dispatchat the pin;patches/litert_google_tensor_dispatch_oss.patchdrops an unused internal dependency.- It loads the Pixel's own
libedgetpu_litert.so. flutter_edge_ai_litertlmbundles it only for an app that setsgoogle_tensor_npu: true.- The directory it is built from is covered by Google's Tensor SDK terms (
TERMS_OF_USE.mdthere) besides the sources' own headers.
Verified with the libraries in these archives. Provenance per run was checked by sha256 on Linux and Windows, LC_UUID on Apple, and ELF build ID in the APK on Android.
Platform LLM ( litertlm_ffi_test)Tools (CPU / GPU) Stop/rewind EmbeddingGemma 2 STT / TTS macOS arm64 22 + 5 NPU skipped 6/6 12/12 22/22 pass iOS (iPhone 17 Pro, iOS 26.5) 22 + 5 NPU skipped, GPU (Metal) ~52–56 chunks/s 6/6 / 6/6 12/12 CPU, 12/12 GPU 22/22 pass Android, Galaxy S25 Ultra ( pa3q-35, Adreno 830, SM8750)35/35, CPU + GPU + Qualcomm NPU 6/6 / 6/6 GPU 13/14 ¹ 22/22 — Android, Pixel 8a ( akita-34, Mali-G715)35/35, CPU + GPU — / 6/6 GPU 13/14 ¹ 22/22 — Android emulator (arm64, API 36, CPU) — — — — pass Linux x86_64 (GCE, T4) 22 + 5 NPU skipped, GPU ~80 chunks/s 6/6 / 6/6 12/12 22/22 pass Linux arm64 (GCE Ampere, CPU) same results as -e(no GPU on this VM)4/4 public models 12/12 22/22 pass Windows x86_64 (Lunar Lake, Arc 140V) 25 + 2 skipped 6/6 / 6/6 12/12 22/22 pass ¹ One case, the same on both OpenCL GPUs: after a stopped audio turn the model said no city was mentioned, where the test expected the city on every GPU (calibrated on Metal, which passes it on the iPhone). The audio is there: in a probe on a Galaxy S24 (Adreno 750) the model, asked next to repeat the recording, wrote it word for word, and a stop at "OK." or no stop gave the city. The test now checks Android's GPU as it checks the CPU (#688).
NPU:
- Intel Lunar Lake 258V: NPU group 3 passed, 2 skipped (no Windows bundle with vision/audio towers);
engine_create0.8–1.1 s, ~61 chunks/s, greedy run1 == run2, no0xC0000409. - Qualcomm SM8750 (Galaxy S25 Ultra): NPU group and NPU vision/audio (towers on
- All seven archives:
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Flutter Edge AI
On-device AI for Flutter on Android, iOS, Web, macOS, Windows and Linux. Run any model a registered engine runs, or the model the operating system already ships, with text, vision, audio, function calling, embeddings, RAG and speech. No server, no cloud.
Website · Docs · Models · Codelabs · pub.dev
The core package is small: it installs models and hands them to engines. Every runtime, store and feature is a separate opt-in package, so an app ships only what it uses. Start with the core README or Getting started.
Packages
| Package | What it does | Docs |
|---|---|---|
flutter_edge_ai | Core: model installation, the engine registry, sessions and chat. Required by every package except diagnostics and genkit_hybrid. | pub.dev · site |
| Engines | ||
flutter_edge_ai_litertlm | LiteRT-LM (.litertlm) through dart:ffi on the five native platforms plus web; CPU, GPU and NPU; the LiteRT embedding backend. | pub.dev · site |
flutter_edge_ai_mediapipe | MediaPipe (.task) on Android, iOS and web. Google's LLM Inference API is maintenance-only; new apps should use .litertlm. | pub.dev · site |
flutter_edge_ai_llama | llama.cpp (.gguf) through llamadart on Android, iOS, macOS, Windows, Linux and web; native LoRA. | pub.dev · site |
flutter_edge_ai_onnx | ONNX Runtime: GenAI inference and embeddings natively, Transformers.js and onnxruntime-web on web. | pub.dev · site |
flutter_edge_ai_builtin_ai | The OS model, nothing to download: Gemini Nano (Android), Apple Foundation Models (iOS, macOS), Windows AI Foundry, the browser Prompt API. | pub.dev · site |
| Embeddings and RAG | ||
flutter_edge_ai_embeddings | Embedding tokenizers (Gemma SentencePiece, BERT WordPiece) for .tflite and .onnx embedders. | pub.dev · site |
flutter_edge_ai_rag | On-device RAG: RagIndex, embedding profiles, filters and the vector-store contract. | pub.dev · site |
flutter_edge_ai_sqlite | SQLite (sqlite-vec) vector store on every platform, web included. | pub.dev · site |
flutter_edge_ai_qdrant | Qdrant Edge vector store on native platforms. | pub.dev · site |
| Speech, agents, diagnostics | ||
flutter_edge_ai_speech | Speech-to-text, text-to-speech and the VoiceSession voice loop. | pub.dev · site |
flutter_edge_ai_agent | Agent skills (SKILL.md) the model picks and runs: text, JS, native intents and MCP tools. | pub.dev · site |
flutter_edge_ai_diagnostics | Process memory diagnostics on Android, iOS, macOS, Linux and Windows. | pub.dev · site |
| Genkit | ||
genkit_flutter_edge_ai | Genkit Dart plugin: on-device models and embedders as Genkit models. | pub.dev · site |
genkit_hybrid | Hybrid routing for Genkit: on-device and cloud models behind one routing policy. Depends only on genkit. | pub.dev · site |
Which package you need for which task, and how they fit together: Packages and Capabilities.
Maintainers
| Maintainer | Looks after |
|---|---|
| Sasha Denisov (@DenisovAV) | Lead maintainer: the core API, the engines, the native builds and every release |
| Jhin Lee (@leehack) | flutter_edge_ai_llama |
| Francesco Vezzani (@kekko7072) | flutter_edge_ai_builtin_ai |
| Samarthsinh Vala (@samarthsinh2660) | flutter_edge_ai_diagnostics |
| Daisuke Majima (@john-rocky) | The Hugging Face integration: installing a model straight from its repository |
Everyone else who has contributed, and more about each maintainer: flutteredge.ai/contributors.
Repository
packages/— every package above, as one Dart pub workspace. The example app with its integration tests ispackages/flutter_edge_ai/example.codelabs/— the step-by-step apps behind the codelabs.website/— the source of flutteredge.ai.
More: Migration guide ·
Desktop support ·
Contributing.
The family shipped as flutter_gemma* up to core 1.11.4; those names stay
published as they are.
License
MIT — see LICENSE.