Skip to content
pubscout

flutter_onnxruntime

1.9.0, released 7 weeks ago by masic.ai

A native wrapper plugin for running ONNX Runtime models across multiple platforms.

$ flutter pub add flutter_onnxruntime
Source repository

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.

Works with

Packages commonly used together with flutter_onnxruntime: ones it builds on, ones built on it, and its own family.