This page shows you how to set up your development environment to use MediaPipe Tasks in your Flutter and Dart applications. Each task runs Google's MediaPipe runtime for the platform it runs on, and Google's pinned models are bundled with your app at build time.
Supported platforms and versions
To create Flutter applications with MediaPipe Tasks, your development environment requires the following:
- Flutter 3.47 or newer. The latest stable release is recommended.
- One or more of the following target platforms:
- Android 9 (API level 28) or higher
- iOS 15.0 or higher
- macOS 14.0 or higher on Apple Silicon
- Linux x64
- Windows x64
- Web
All tasks run on every platform listed above, except Text Proofreader and Text Summarizer, which are not yet available on the web. This matches the MediaPipe Tasks Web SDK, which doesn't support these two tasks. For per-platform requirements, see Platform notes.
MediaPipe Tasks dependencies
MediaPipe Tasks provides five Flutter packages for vision, text, audio,
retrieval, and decision tasks. Add only the packages your app uses: each one
bundles only the MediaPipe library for its domain. Every package depends on
mediapipe_core, which holds the shared model store and web runtime settings,
and re-exports its types, so you don't need to add mediapipe_core yourself.
Vision tasks
The MediaPipe Tasks vision package
(mediapipe_vision) contains tasks
that process images, video frames, and live camera streams (such as Face
Landmarker, Hand Landmarker, Pose Landmarker, Object Detector, and Image
Segmenter). See
Prepare vision input data for
supported inputs.
flutter pub add mediapipe_vision
Text tasks
The MediaPipe Tasks text package
(mediapipe_text) contains tasks
that analyze and embed text strings (such as Text Classifier, Language Detector,
and Text Embedder), plus Text Proofreader and Text Summarizer on platforms other
than the web.
flutter pub add mediapipe_text
Audio tasks
The MediaPipe Tasks audio package
(mediapipe_audio) contains tasks
that classify audio clips and streams, transcribe speech, and synthesize speech
(Audio Classifier, Audio Transcriber, and Text-to-Speech). See
Prepare audio input data for
supported inputs.
flutter pub add mediapipe_audio
Retrieval tasks
The MediaPipe Tasks retrieval package
(mediapipe_retrieval) provides
text, image, and audio embeddings in a shared embedding space and an on-device
vector index over them (Universal Embedder and Semantic Retriever).
flutter pub add mediapipe_retrieval
Decision tasks
The MediaPipe Tasks decision package
(mediapipe_decision) answers
yes-or-no, choice, and score questions about a text (Decision Maker).
flutter pub add mediapipe_decision
Bundle models
Apps bundle the models they use at build time, so nothing is downloaded at run time and the app works offline from its first launch.
In your app's
pubspec.yaml, declare theassets/mediapipe/folder and list the models each package uses underhooks.user_defines. Each package'sXxxModels.byName(for example,VisionModels.byName) lists the names it accepts.flutter: assets: - assets/mediapipe/ hooks: user_defines: mediapipe_vision: models: [face_landmarker, hand_landmarker] mediapipe_audio: models: [yamnet]From your app's root, download and verify the listed models. Run this command again whenever the list changes:
dart run mediapipe_core:bundle_modelsThe command downloads each listed model, checks it against its pinned SHA-256 hash, writes it into
assets/mediapipe/, and removes models that are no longer listed.In continuous integration, verify that the folder matches the list without changing it:
dart run mediapipe_core:bundle_models --check
Then create a task with the bundled model:
import 'dart:typed_data';
import 'package:mediapipe_vision/mediapipe_vision.dart';
Future<int> countFaces(Uint8List rgba, int width, int height) async {
final landmarker = await FaceLandmarker.create(
FaceLandmarkerOptions(model: VisionModels.faceLandmarker),
);
try {
final result = await landmarker.detect(
VisionImage.fromPixels(
pixels: rgba,
width: width,
height: height,
format: VisionPixelFormat.rgba,
),
);
return result.faceLandmarks.length;
} finally {
await landmarker.dispose();
}
}
If a model isn't bundled, create throws a RuntimeUnavailableException whose
fix names the pubspec.yaml entry to add. To use your own model, pass
modelPath or modelBytes in the task options instead of model.
Download models at run time
Downloading models at run time is opt-in. To let model: download models that
your app doesn't bundle, set ModelStore.allowDownloads before you create any
tasks:
ModelStore.allowDownloads = true;
Downloaded models are verified against the same pinned hashes and cached on the device. Run-time downloads need network access: see the Android and macOS notes in Platform notes.
Platform notes
Android
- Set
minSdkto 28 (Android 9) or higher inandroid/app/build.gradle(.kts). - Tasks run on arm64-v8a and x86_64. On 32-bit devices (armeabi-v7a), the vision and audio tasks and the Text Classifier, Text Embedder, and Language Detector tasks run on the CPU. Decision Maker, the retrieval tasks, EmbeddingGemma, Text Proofreader, Text Summarizer, Audio Transcriber, and Text-to-Speech require a 64-bit device.
- On the Android emulator, only the CPU delegate is available.
To download models at run time, add the
INTERNETpermission toandroid/app/src/main/AndroidManifest.xml. Flutter adds it only to debug and profile builds, so release builds need it explicitly:<uses-permission android:name="android.permission.INTERNET"/>
iOS
- Set the deployment target to iOS 15.0 or higher.
- On the iOS Simulator, only the CPU delegate is available.
- For App Store submission, declare the required-reason APIs that the
MediaPipe libraries call in your app's
ios/Runner/PrivacyInfo.xcprivacy. See App Store privacy manifest for the categories to declare.
macOS
- macOS 14.0 or higher on Apple Silicon is required.
Build the app for Apple Silicon only. Release and profile builds also build an Intel (x86_64) slice by default, which the MediaPipe libraries don't provide, so those builds fail. Add these lines to
macos/Runner/Configs/AppInfo.xcconfig:ARCHS = arm64 EXCLUDED_ARCHS = x86_64Alternatively, run
flutter config --enable-macos-arm64-onlyto apply the same setting to every app built on that machine.To download models at run time, a sandboxed app needs the network client entitlement in
macos/Runner/DebugProfile.entitlementsandmacos/Runner/Release.entitlements:<key>com.apple.security.network.client</key> <true/>
Linux
The MediaPipe Linux library loads EGL and OpenGL ES, even for CPU inference. On Debian or Ubuntu, install them with:
sudo apt-get install libegl1 libgles2
Windows
- Tasks run on the CPU.
Web
- By default, the MediaPipe JavaScript and WebAssembly runtimes load from jsDelivr, and each file is checked against a pinned SHA-384 hash before it runs. Bundled models load from your app's own assets.
To host the runtimes yourself (for offline use, an intranet, or a strict Content Security Policy), copy them into your app from its root:
dart run mediapipe_core:web_runtime web/mediapipeThen set the base URL before you create the first task:
MediaPipeWebRuntime.baseUrl = 'mediapipe/';If your site sends a Content Security Policy, allow
'self'andblob:inscript-srcandworker-src,'wasm-unsafe-eval'for WebAssembly, and'self'andhttps://cdn.jsdelivr.net(unless self-hosted) inconnect-src. Addhttps://storage.googleapis.comtoconnect-srconly if you download models at run time.Decision Maker and the retrieval tasks require WebGPU in the browser.
Samples and resources
- Live gallery: try every supported task in your browser.
- flutter-mediapipe on GitHub: source, the gallery app, a runnable sample for every task and running mode, and an object detection app for every platform.
Troubleshooting
For help with technical questions related to MediaPipe, visit the discussion group or Stack Overflow for support from the community. To report bugs or make feature requests for the Flutter packages, file an issue on GitHub.