Search packages, repositories and app categories

Package detailsv1.4.1

onnxruntime

Flutter plugin for OnnxRuntime provides an easy, flexible, and fast Dart API to integrate Onnx models in flutter apps across mobile and desktop platforms.

AndroidiOSmacOSWindowsLinux
30-day downloads
19K
Likes
73
Pub points
150

Install package

flutter pub add onnxruntime

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The onnxruntime Flutter plugin enables seamless integration of ONNX (Open Neural Network Exchange) models into Flutter applications across Android, iOS, macOS, Windows, and Linux. It provides a fast, flexible, and easy-to-use Dart API for running machine learning inference directly within apps. Ideal for deploying pre-trained models with minimal overhead, it supports a wide range of ML tasks including image recognition, object detection, and natural language processing. The plugin leverages the performance of the underlying ONNX Runtime engine while maintaining cross-platform compatibility.

Use cases

  • Image classification
  • Object detection
  • Natural language processing
  • Real-time inference in mobile apps
  • Desktop ML applications

Key features

  • Cross-platform support
  • High-performance inference
  • Simple Dart API
  • ONNX model compatibility
  • Lightweight integration

Suitable for

  • Developers building ML-powered Flutter apps
  • Teams using ONNX models
  • Applications requiring real-time inference
  • Mobile and desktop ML deployment
  • Projects needing platform-agnostic ML

Considerations

  • Requires ONNX model conversion
  • Limited to ONNX-compatible models
  • Model size impacts app bundle
  • No built-in model training
  • Platform-specific runtime dependencies

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

OnnxRuntime Plugin

pub package

Overview

Flutter plugin for OnnxRuntime via dart:ffi provides an easy, flexible, and fast Dart API to integrate Onnx models in flutter apps across mobile and desktop platforms.

Platform Android iOS Linux macOS Windows
Compatibility API level 21+ * * * *
Architecture arm32/arm64 * * * *

*: Consistent with Flutter

Key Features

  • Multi-platform Support for Android, iOS, Linux, macOS, Windows, and Web(Coming soon).
  • Flexibility to use any Onnx Model.
  • Acceleration using multi-threading.
  • Similar structure as OnnxRuntime Java and C# API.
  • Inference speed is not slower than native Android/iOS Apps built using the Java/Objective-C API.
  • Run inference in different isolates to prevent jank in UI thread.

Getting Started

In your flutter project add the dependency:

dependencies:
  ...
  onnxruntime: x.y.z

Usage example

Import
import 'package:onnxruntime/onnxruntime.dart';
Initializing environment
OrtEnv.instance.init();
Creating the Session
final sessionOptions = OrtSessionOptions();
const assetFileName = 'assets/models/test.onnx';
final rawAssetFile = await rootBundle.load(assetFileName);
final bytes = rawAssetFile.buffer.asUint8List();
final session = OrtSession.fromBuffer(bytes, sessionOptions!);
Performing inference
final shape = [1, 2, 3];
final inputOrt = OrtValueTensor.createTensorWithDataList(data, shape);
final inputs = {'input': inputOrt};
final runOptions = OrtRunOptions();
final outputs = await _session?.runAsync(runOptions, inputs);
inputOrt.release();
runOptions.release();
outputs?.forEach((element) {
  element?.release();
});
Releasing environment
OrtEnv.instance.release();

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.