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.

native-v0.19.0-a发布于 2026-11-04 11:47 UTC657star +3 / 7 天179fork同步于 2026-11-10 17:57 UTC

怎么上手

由 README 提炼,执行前请确认
flutter pub add flutter_edge_ai
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求;引擎覆盖 CPU、GPU 与 NPU,并支持 Android、iOS、Web、macOS、Windows、Linux 六端。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Flutter 端侧 AI 框架,在六端本地跑 LLM、多模态、RAG 与语音,无需服务器

让 Flutter 应用在手机、桌面和 Web 上直接跑 Gemma 等大模型,支持多模态、函数调用、向量嵌入、RAG 和语音,不用依赖云端。

核心能力

  • 核心包只负责装模型和引擎注册,按需引入运行时包
  • 支持 LiteRT-LM、llama.cpp、ONNX、MediaPipe 多种引擎
  • 可直接调用系统自带模型如 Gemini Nano 与 Apple Foundation Models
  • 内置端侧 RAG:嵌入、向量存储与 SQLite/Qdrant 后端
  • 提供语音识别合成、Agent 技能与 Genkit 混合路由

容易踩的坑

核心包不含运行时,需按需另装引擎包如 flutter_edge_ai_litertlm 或 flutter_edge_ai_llama;除系统自带模型外,模型需单独下载安装;MediaPipe 引擎的 LLM Inference API 仅维护,新项目建议用 .litertlm。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本native-v0.19.0-a
  1. 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_litertlm on LiteRT-LM v0.19.0.

    Pins: LiteRT-LM 771b06e1 (v0.19.0; the tag later moved to 83ce6067, which changes only Package.swift and README.md). LiteRT dcb657e8. 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.19 at 37d1ec59 (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_litertlm release built on the C API 1.0 client. Releases up to 1.19.x keep using native-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 as context_full, also when no prefill chunk fits. Only the context-window checks report it; any other RESOURCE_EXHAUSTED, such as a failed allocation, ends the turn failed. A send refused before it starts (a NULL argument, a message that is not JSON) is reported as refused (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) and stream_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.so and libLiteRtTopKOpenClSampler.so are 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_64 fc4e17a9…, arm64 4685001b…).

    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
  2. 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. Its hook/build.dart fetches this zip at build time and checks its SHA-256.

    Why not Microsoft's AAR. The libonnxruntime-genai.so in Microsoft's 0.17.0 Android AAR lists libmat.so (the 1DS telemetry SDK) in DT_NEEDED. That libmat.so is 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, commit 1d67be30e5b1ed0c264f6f41c598f85157e8288b.
    • Built against ONNX Runtime 1.27.0: headers and libonnxruntime.so from Maven Central com.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.so only.
    • Every PT_LOAD segment has p_align 0x4000, and the hook's own check (requireAndroidPageAlign) accepts it.
    • The library contains no OneCollector string and no 1DS endpoint.

    Asset.

    FileSHA-256
    onnxruntime-genai-android-0.17.0-a.zip (contains jni/arm64-v8a/libonnxruntime-genai.so, the AAR's layout)fe491a77f3bac8e72ae45814394a705a1c8bbf3aa69e1fd97106d8d1ea6cef76

    The 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 in hook/build.dart.

    The -a suffix 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_onnx with 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.

  3. native-v0.18.0-hNative dylibs native-v0.18.0-h2026-10-27 · 2026-10-27 11:52 UTC
    查看更新说明

    native-v0.18.0-g with the Windows archive changed alone.

    Windows: both copies of libLiteRtWebGpuAccelerator.dll (lib-prefixed and not) are Google's prebuilt from LiteRT-LM 5f973f57 (sha256 2fb3583681ffb28d2fa8c08803445839e579a8e67417bde480415a4360e18ed0), 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-h
    12B, 25-token promptempty textcorrect answer, first token 1.07 s
    12B, 7271-token prefill (original file)19.8 s28.5–29.0 s
    12B, 7271-token prefill (prefill_1024 build)21.4–22.7 s31.3–32.2 s
    12B decode12.5–12.7 tok/s13.0–13.1 tok/s
    Gemma 4 E2B GPU decode62.1 tok/s65.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_PTL on 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; its webgpu_dawn.dll imports resolve against the shipped Dawn, byte-identical at both upstream refs. The other 23 Windows files and the six other archives are byte-identical to native-v0.18.0-g.

    Archivesha256
    litertlm-windows_x86_64.tar.gz9b550ad40c5ef33346596d21df9498217eb96662a7bd457272b6c5e6742d5d59
    GemmaModelConstraintProvider.xcframework.zip23bd0dead9e6d01641eedc1a2dae3441bb381363b03319ab4ab028b60b94c9ac
    LiteRtLmMetalAccelerator.xcframework.zipe7cc3c25d9e82ef72f44e47724192bf3e2ce3ce757fde50be8c0dd98a26a7427
    the six other archivesunchanged from native-v0.18.0-g

    macOS, Swift Package Manager: the two companion zips that macos/flutter_edge_ai_litertlm/Package.swift fetches are packaged for this tag from its macOS archive (the same bytes as -g's: same LC_UUID). Their CFBundleVersion is now numeric (0.18.8), the tag is in DevFlutteredgeNativeTag, and the zips no longer depend on the packager's timezone. checksums_spm_macos.txt lists them.

  4. native-v0.18.0-gNative dylibs native-v0.18.0-g2026-10-21 · 2026-10-21 11:35 UTC
    查看更新说明

    native-v0.18.0-f with the Windows archive changed alone: the Intel NPU stack moves from OpenVINO 2026.3.1 to 2026.4.1, and openvino_intel_npu_vm_runtime.dll joins it (#702). Same pins as -f: LiteRT-LM b2f686e2 (v0.18.0), LiteRT 26895c9f, 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 (commit 79649ded); openvino_intel_npu_vm_runtime.dll is new. The other twelve files are byte-identical to -f.
    • Android, iOS, iOS simulator, macOS, Linux x86_64, Linux arm64: the -f archives, byte for byte (same sha256).

    OpenVINO 2026.4.1. patches/litert_openvino_2026_4_1.patch is upstream LiteRT 991d15588a, 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.dll is 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_test with 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 / NPU30.0 / 23.5 / 53.6 tok/s24.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_PTL on 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_create 0.9–1.0 s, 59.6 tok/s, greedy run1 == run2
  5. native-v0.18.0-fNative dylibs native-v0.18.0-f2026-10-18 · 2026-10-18 21:18 UTC
    查看更新说明

    native-v0.18.0-e plus 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-LM b2f686e2 (v0.18.0), LiteRT 26895c9f, Qualcomm dispatch against QAIRT 2.50.0.

    What changed, per archive. Every file not listed here is byte-identical to -e, Android's libLiteRtDispatch_Qualcomm.so and Linux arm64's Qualcomm dispatch and libcdsprpc.so shim included:

    • All seven archives: libLiteRtLm and StreamProxy.
    • 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 the libLiteRtLm it drives and passes them in, so the shim keeps no global state. stream_proxy_create is 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_AUX section (every AOT NPU bundle) was loaded through a C runtime file descriptor.
    • Google's prebuilt libLiteRt.dll links its own C runtime, so it cannot read that descriptor; on v0.18.0 the process ended with 0xC0000409.
    • 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.so is built from LiteRT's litert/vendors/google_tensor/dispatch at the pin; patches/litert_google_tensor_dispatch_oss.patch drops an unused internal dependency.
    • It loads the Pixel's own libedgetpu_litert.so.
    • flutter_edge_ai_litertlm bundles it only for an app that sets google_tensor_npu: true.
    • The directory it is built from is covered by Google's Tensor SDK terms (TERMS_OF_USE.md there) 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.

    PlatformLLM (litertlm_ffi_test)Tools (CPU / GPU)Stop/rewindEmbeddingGemma 2STT / TTS
    macOS arm6422 + 5 NPU skipped6/612/1222/22pass
    iOS (iPhone 17 Pro, iOS 26.5)22 + 5 NPU skipped, GPU (Metal) ~52–56 chunks/s6/6 / 6/612/12 CPU, 12/12 GPU22/22pass
    Android, Galaxy S25 Ultra (pa3q-35, Adreno 830, SM8750)35/35, CPU + GPU + Qualcomm NPU6/6 / 6/6GPU 13/14 ¹22/22—
    Android, Pixel 8a (akita-34, Mali-G715)35/35, CPU + GPU— / 6/6GPU 13/14 ¹22/22—
    Android emulator (arm64, API 36, CPU)————pass
    Linux x86_64 (GCE, T4)22 + 5 NPU skipped, GPU ~80 chunks/s6/6 / 6/612/1222/22pass
    Linux arm64 (GCE Ampere, CPU)same results as -e (no GPU on this VM)4/4 public models12/1222/22pass
    Windows x86_64 (Lunar Lake, Arc 140V)25 + 2 skipped6/6 / 6/612/1222/22pass

    ¹ 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_create 0.8–1.1 s, ~61 chunks/s, greedy run1 == run2, no 0xC0000409.
    • Qualcomm SM8750 (Galaxy S25 Ultra): NPU group and NPU vision/audio (towers on

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Flutter Edge AI

    pub package License: MIT

    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

    PackageWhat it doesDocs
    flutter_edge_aiCore: model installation, the engine registry, sessions and chat. Required by every package except diagnostics and genkit_hybrid.pub.dev · site
    Engines
    flutter_edge_ai_litertlmLiteRT-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_mediapipeMediaPipe (.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_llamallama.cpp (.gguf) through llamadart on Android, iOS, macOS, Windows, Linux and web; native LoRA.pub.dev · site
    flutter_edge_ai_onnxONNX Runtime: GenAI inference and embeddings natively, Transformers.js and onnxruntime-web on web.pub.dev · site
    flutter_edge_ai_builtin_aiThe 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_embeddingsEmbedding tokenizers (Gemma SentencePiece, BERT WordPiece) for .tflite and .onnx embedders.pub.dev · site
    flutter_edge_ai_ragOn-device RAG: RagIndex, embedding profiles, filters and the vector-store contract.pub.dev · site
    flutter_edge_ai_sqliteSQLite (sqlite-vec) vector store on every platform, web included.pub.dev · site
    flutter_edge_ai_qdrantQdrant Edge vector store on native platforms.pub.dev · site
    Speech, agents, diagnostics
    flutter_edge_ai_speechSpeech-to-text, text-to-speech and the VoiceSession voice loop.pub.dev · site
    flutter_edge_ai_agentAgent skills (SKILL.md) the model picks and runs: text, JS, native intents and MCP tools.pub.dev · site
    flutter_edge_ai_diagnosticsProcess memory diagnostics on Android, iOS, macOS, Linux and Windows.pub.dev · site
    Genkit
    genkit_flutter_edge_aiGenkit Dart plugin: on-device models and embedders as Genkit models.pub.dev · site
    genkit_hybridHybrid 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

    MaintainerLooks 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

    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.