platform_interface library

What the family packages and platform plugins need from core and apps do not: model resolution, the runtime tables behind the capability queries, the checks every family shares, and the host details of Google's C API.

Applications should import a family's library instead.

Classes

ClassifierSettings
The settings every classifier takes: Image Classifier, Object Detector, Text Classifier, Language Detector, Audio Classifier and Gesture Recognizer's heads. Each task's options document them for that task.
ModelSource
Where a verified model is: a file path on native platforms, bytes in browsers. What ModelStore returns and a task reads.
SerialTaskQueue
A task's requests, run one at a time in the order they were added. A request that fails does not stop the next, and close waits for every request added before it.

Constants

largeModelNeeds64Bit → const String
Why a task on largeModelRuntimeTargets refuses 32-bit Android.
largeModelRuntimeTargets → const Map<String, String?>
tasksRuntimeTargets on 64-bit processes only, for the tasks whose models need more memory than a 32-bit Android phone gives an app: Decision Maker's, the retrieval tasks', EmbeddingGemma, and the Proofreader's and Summarizer's.
maxStreamTimestampMilliseconds → const int
The largest timestamp any platform accepts for a frame or an audio block: JavaScript's exact integer range in milliseconds (about 285 years), which native runtimes exceed, so one limit keeps the same input valid everywhere.
tasksRuntimeTargets → const Map<String, String?>
Process targets where each task family bundles Google's MediaPipe library for that family, which serves the Audio Classifier and every text task: the classifier, embedder (EmbeddingGemma included), language detector, Proofreader and Summarizer.

Properties

mpAppId → String?
Browsers run no C API, so no app ID goes through it.
no setter
mpAppVersion → String?
Browsers run no C API, so no app version goes through it.
no setter
mpHostSystem → int
Browsers have no host system value; the native runtime is never loaded.
no setter
mpHostVersion → String
Browsers have no host version value: Google's JavaScript runtime reports its own.
no setter
taskPlatformGpuReader ↔ Future<String?> Function()?
Names this device's GPU for TaskPlatform.gpu. An adapter package that can read it sets this when it registers, before the platform is first read; it is called once, with the rest of the platform.
getter/setter pair

Functions

checkClassifierSettings(ClassifierSettings settings) → void
Validates settings as Google's runtime would.
checkLabel(String value, String name) → void
Requires a nonempty metadata label without NUL.
checkStreamTimestamp(int timestampMilliseconds, int? previous) → void
Throws ArgumentError unless timestampMilliseconds is nonnegative, at most maxStreamTimestampMilliseconds and above previous, the last timestamp the task accepted (null before the first): Google's runtimes refuse a timestamp that does not increase.
classifierSettingsJson(ClassifierSettings settings) → Map<String, Object?>
settings named as in Google's JavaScript API, for the browser adapters.
cosineSimilarity(Embedding first, Embedding second) → double
Cosine similarity of two embeddings of the same representation and size, computed in Dart so every platform gives the same answer. Quantized bytes are read as signed 8-bit values, as Google's APIs do.
currentTaskPlatform() → Future<TaskPlatform>
Web has no packaged native task runtime. The GPU is what a registered plugin's taskPlatformGpuReader names, such as the browser's WebGPU adapter, read once; the engine is what the user agent names.
decodeCategory(Map<Object?, Object?> json) → MediaPipeCategory
Decodes a category. A missing index is -1, as Google's C API reports it.
decodeClassifications(Map<Object?, Object?> json) → Classifications
Decodes one classification head and its categories.
decodeEmbedding(Map<Object?, Object?> json) → Embedding
Decodes one embedding head: its float values or its scalar-quantized bytes, as typed arrays or JSON lists.
decodeLabel(Object? value) → String?
Google's browser runtime reports an absent label as an empty string; its C and Python APIs report none, as the Dart API does.
hasHardwareWebGpu(TaskPlatform platform) → bool
Whether platform names a hardware WebGPU adapter, the only one Google's browser Decision Maker answers on and its Universal Embedder runs on.
holdModelBytes(TaskOptions options, Uint8List bytes) → void
Keeps bytes as options' model, for a runtime that reopens its task after the model file may be gone (see GpuFrameBudget in mediapipe_vision).
missingLinuxGraphicsLibraries(String loaderError) → StateError?
Browsers load no native library, so no loader error names one.
nativeModelPath(String path) → String
Model paths pass through unchanged off dart:io platforms.
pluginNotRegistered(String package) → RuntimeUnavailableException
What a family reports in a browser where package's plugin never registered: its native stubs throw it, and its capability queries give its message and fix as their reason.
requireDelegate(TaskCapabilities capabilities, Delegate delegate) → void
Fails with the capability query's reason when delegate is unavailable, so every task's create refuses a delegate the same way on every platform.
resolvePinnedModel(DownloadAsset model, {String? family, Map<String, DownloadAsset> registry = const {}}) → Future<ModelSource>
Resolve a pinned model to its verified copy: the cached one (a native file, or bytes in the browser's Cache Storage), else the app's bundled copy, else a download when ModelStore.allowDownloads is on.
resolveTaskModel(TaskOptions options) → Future<void>
Resolves a pinned TaskOptions.model before a task opens Google's runtime: every task's create calls this first. A path or bytes need nothing.
runJniOnLoad(Object symbol) → void
Browsers load no Android library, so there is no JNI_OnLoad to run.
taskException(Object error) → MediaPipeException
Google's failure as the one exception every task reports: a MediaPipeException as it is, and anything else as a TaskException that keeps it as its cause.
tasksRuntimeUnavailable(String task, String operatingSystem) → String
Why task cannot run in this process on operatingSystem (TaskPlatform.operatingSystem): the build bundled no MediaPipe library for it, as happens when the app was built without its package's build hook running.
tasksRuntimeVersionOn(TaskPlatform platform) → String
The official MediaPipe release behind the tasks on platform: Google's 1.2.2 per-family libraries (its release build of November 2, 2026) on Android, iOS, macOS, Linux and Windows, and in browsers the npm runtime each family's assets/runtime.json pins.