flutter_onnxruntime
1.9.0, released 7 weeks ago by masic.ai
A native wrapper plugin for running ONNX Runtime models across multiple platforms.
What it does
It provides a lightweight wrapper to run ONNX machine learning models and inference sessions directly on Android, iOS, web, Windows, macOS, and Linux. Libraries are dynamically fetched during installation, and memory safety is handled in native code.
AI-written summary of version 1.9.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to execute ONNX-format machine learning models locally on device.
- You require multi-platform ML inference support including mobile, desktop, and web.
Skip it when
- You need features not yet supported by the plugin like model metadata or input/output info on Swift/JS APIs.
- Your target iOS/macOS version is below the required 16.0 / 14.0 minimum deployments.
Strengths
- Supports multiple platforms (Android, iOS, web, Windows, macOS, Linux).
- Fetches binaries directly from official repositories so libraries are up-to-date.
- Handles memory management in native code to reduce leaks.
Weaknesses
- Retrieving model metadata and input/output info is unavailable on Swift and Javascript APIs.
- Requires specific manual configuration for Android ProGuard and OS minimum versions on iOS/macOS.
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 3
Requires adding ProGuard rules for Android, and minimum OS version configuration (iOS 16, macOS 14) for Apple platforms.
import 'package:flutter_onnxruntime/flutter_onnxruntime.dart';
final ort = OnnxRuntime();
final session = await ort.createSessionFromAsset('assets/models/addition_model.onnx');
final inputs = {
'A': await OrtValue.fromList([1, 1, 1], [3]),
'B': await OrtValue.fromList([2, 2, 2], [3])
};
final outputs = await session.run(inputs);
print(await outputs['C']!.asList());Alternatives
Packages that do the same job and could replace flutter_onnxruntime.
- tflite_flutter
Pick tflite_flutter if your machine learning models are in TensorFlow Lite format instead of ONNX.
68Compare
Works with
Packages commonly used together with flutter_onnxruntime: ones it builds on, ones built on it, and its own family.
- webflutter_onnxruntime depends on itLightweight bindings for browser APIs via JS interop
- plugin_platform_interfaceflutter_onnxruntime depends on itReusable base class for platform interfaces of Flutter federated plugins.
- path_providerflutter_onnxruntime depends on itProvides Flutter APIs to locate common filesystem directories on Android, iOS, macOS, Linux and Windows.
- image_background_removerBuilt on flutter_onnxruntimeRemoves backgrounds from images offline using an ONNX machine learning model.
- mobile_rag_engineBuilt on flutter_onnxruntimeBuild local, on-device RAG in Flutter with semantic search and hybrid retrieval.