Documentation for v0.10.0, an older release. Read v0.11.1, the latest release

Install llamadart

Add llamadart to a Dart or Flutter app, set up Apple and web targets, verify the install, and customize the prebuilt native runtimes.

On this page

Requirements#

  • Dart SDK >= 3.10.7
  • Flutter SDK >= 3.38.0 (if you build Flutter apps)
  • Flutter iOS apps: deployment target 16.4 or newer
  • Flutter macOS apps: deployment target 14.0 or newer
  • Windows: the latest Microsoft Visual C++ v14 Redistributable for the app's architecture (x64 or arm64) on every machine that runs the app, at least as new as the build tools of the bundled DLLs. Stock Windows Server lacks it; see Native library won't load.

Add the package#

dependencies:
  llamadart: ^0.10.0

Then resolve packages:

dart pub get
# or
flutter pub get

Flutter iOS and macOS setup#

Set the app's deployment target before running: iOS 16.4 or newer, macOS 14.0 or newer. In Xcode, set IPHONEOS_DEPLOYMENT_TARGET = 16.4 or MACOSX_DEPLOYMENT_TARGET = 14.0 for the Runner configurations. An iOS app that still uses CocoaPods also needs the Podfile platform:

platform :ios, '16.4'

To link the Apple XCFrameworks through Swift Package Manager, add the runtime companion packages you need:

dependencies:
  llamadart: ^0.10.0
  llamadart_llama_cpp_flutter: ^0.0.20 # GGUF / llama.cpp
  llamadart_litert_lm_flutter: ^0.0.12 # Apple .litertlm / LiteRT-LM targets
  llamadart_stable_diffusion_flutter: ^0.0.1 # Apple image generation, opt-in

Pair companion 0.0.20 with core 0.10.0. The build checks the resolved llama.cpp and stable_diffusion companions' runtime pins and fails on a mismatch or on an unverified local Artifacts override; resolve the matching companion and rerun flutter pub get. Flutter macOS LiteRT-LM builds still use the core package's native-assets runtime rather than SwiftPM.

Pair llamadart_stable_diffusion_flutter 0.0.1 with core 0.10.0 or newer; older cores, including 0.9.x, ignore it. Adding it opts iOS and macOS builds into the image generation runtime (about 37 MB per Apple target) on its own and leaves the other runtimes on their current path, so leave it out unless the app uses ImageGenerationEngine. An app that uses image generation without it gets the hook-bundled runtime, whose iOS framework MinimumOSVersion App Store Connect rejects; only Xcode and xcodebuild show the build warning about it.

Web#

Web apps must load the WebGPU bridge script in their web/index.html; the package does not inject it. See Add the bridge to your app.

AI agent skills#

The package ships agent skills that teach coding agents llamadart's APIs. After pub get, run this from your app's root and pick the skills and agent to install them for:

dart run skills@ get

Rerun it after upgrading llamadart to update the installed skills.

Verify it works#

Run the Quickstart example with maxTokens: 1. If the runtime initializes and the model loads, your setup is complete.

What happens on first build#

On the first dart run / flutter run for a native target, llamadart:

  1. Detects platform and architecture.
  2. Resolves matching runtime artifacts from leehack/llamadart-native and leehack/litert-lm-native.
  3. Wires them into your app through native assets. Flutter iOS builds use SwiftPM-linked XCFrameworks when the matching companion packages are present; Flutter macOS LiteRT-LM can fall back to hook-managed native assets. The opt-in image generation runtime comes from leehack/stable-diffusion-native the same way.

No local C++ toolchain setup is required for consumers.

Customize native runtimes#

Native builds bundle every available runtime family. To ship only one model format, or to test another native build, set hooks.user_defines in your pubspec.yaml:

hooks:
  user_defines:
    llamadart:
      llamadart_native_runtimes: [llama_cpp] # or [litert_lm]
      # Compatibility testing only; omit to use the tested pin.
      # llamadart_native_tag: v0.5.0

A llamadart_native_backends request that names any backend module the target bundle lacks is discarded whole: the hook logs a warning and bundles the defaults instead.

Override tags name a leehack/llamadart-native release: stable vMAJOR.MINOR.PATCH, stable wrapper rebuilds vMAJOR.MINOR.PATCH-N, historical bNNNN, nightly wrapper rebuilds bNNNN-N, or consume-only bNNNN-llamadart.N. Nightly cores are written without leading zeros, and rebuild counters start at 1. Build-hook overrides must always name an explicit tag; latest is limited to maintainer synchronization and header/binding regeneration. An override does not regenerate the Dart bindings, so its binary must stay ABI-compatible with the default leehack/llamadart-native@v0.5.0 runtime.

Every key, per-target backend and Android CPU variant selection, local bundle paths, and fallback rules: Configuring native backend modules. How the hook resolves runtimes and the Apple SwiftPM path: Native build hooks.

Searches the latest release. Esc to close.