flutter_litert 2.8.3
flutter_litert: ^2.8.3 copied to clipboard
LiteRT (formerly TensorFlow Lite) Flutter plugin. Drop-in on-device ML inference with bundled native libraries for supported native platforms and web runtimes.
2.8.3 #
- Android: support both AGP 8 and AGP 9 by moving the plugin Gradle files to Kotlin DSL and updating the Android tooling plugin declarations (6c332e3b).
2.8.2 #
- Fix GPU and CoreML delegates silently falling back to CPU on macOS and iOS (#11). macOS now bundles the GPU/CoreML dylibs that were previously omitted from the Swift Package manifest. iOS retains all 212 packaged LiteRT, Metal, and CoreML symbols that Dart FFI resolves but linker stripping would otherwise drop. They are kept through a generated anchor on both CocoaPods and SPM, plus an embedded dynamic SPM framework so they survive App Store archive stripping. This extends the 2.8.0 mitigation (#8, #9) to every packaged API.
- Log delegate initialization failures before falling back to CPU. A packaging regression can no longer masquerade as unexpectedly slow GPU/CoreML performance.
- On Apple Silicon the Metal GPU is substantially faster for conv-heavy models once actually loaded (for example, selfie segmentation ~27ms -> ~3ms versus XNNPACK).
2.8.1 #
- Complete the AGP 9 / built-in Kotlin fix from 2.8.0 (#10). 2.8.0 resolved the
"Inconsistent JVM-target ... (17) and (21)" error on the AGP 8.11 transitional
path, but a full migration to
android.builtInKotlin=trueon AGP 9 still failed with "The 'org.jetbrains.kotlin.android' plugin is no longer required since AGP 9.0": the Flutter Gradle plugin auto-applies the legacy Kotlin plugin to this module, and AGP 9 rejects it. The plugin now applieskotlin-androidonly on AGP < 9 (which also stops Flutter from auto-applying it), and keeps the JVM-target pin guarded so the AGP-9-without-built-in-Kotlin case is skipped. Verified building against AGP 8.11.1 and 9.0.1 with built-in Kotlin both enabled and disabled.
2.8.0 #
- Fix the "Inconsistent JVM-target compatibility detected ... (17) and (21)" Android build failure under AGP 9 / Flutter 3.44+ (#10). The fix pins the Kotlin JVM target to 17 only when AGP >= 9 is in use, so older Flutter/AGP toolchains are unaffected and the minimum supported versions are unchanged.
- Fix iOS "Failed to lookup symbol 'TfLiteInterpreterOptionsCreate'" crash on App Store / TestFlight builds (#8, #9). The TFLite C symbols are resolved at runtime via dlsym and were stripped during App Store distribution; the CocoaPods podspec now disables that stripping on the app target so no manual Xcode build-setting changes are required.
2.7.0 #
- Add
InterpreterOptions.addCustomOp(...): high-level method for registering custom TFLite ops; handles native string allocation and lifetime internally, replacing the previous rawtfliteBindingcall pattern. - Add
Interpreter.fromBytes(Uint8List): async cross-platform constructor, matching the web API. Native platforms complete immediately; unsupported stub throwsUnsupportedError. - Rename
lastNativeInferenceDurationMicroSeconds→lastInferenceDurationMicrosecondsonInterpreter,SignatureRunner, andLiteRtInterpreter(all platform variants). Old name kept as a@Deprecatedalias. - Rename
configureLiteRtLoader→configureLiteRtWebLoader. Old name kept as a@Deprecatedalias and re-exported fromall_web.dart. - Fix
camera_frame.dart: widen.planescast fromList<dynamic>toIterable<dynamic>for broader compatibility.
2.6.0 #
- Fix iOS Swift Package Manager builds: repackage the bundled TensorFlowLite xcframeworks (correct simulator slice identifiers and framework structure) so they resolve under SPM, including on the iOS simulator.
- Add a standalone example that depends only on
flutter_litertandopencv_dart.
2.5.8 #
- Raise minimum deployment targets to iOS 13.0 / macOS 10.15 to satisfy Swift Package Manager's
FlutterFrameworkrequirement (fixes SPM build failures on macOS/iOS). - Update example and documentation to use
flutter_litert_flex: ^1.0.0.
2.5.7 #
- Update example to use
flutter_litert_flex: ^0.0.8.
2.5.6 #
- Fix SPM: add missing
FlutterFrameworkdependency to iOS and macOSPackage.swift.
2.5.5 #
- Add SPM support for iOS: TensorFlowLiteC, TensorFlowLiteCMetal and TensorFlowLiteCCoreML are now declared as binary targets in Package.swift so the plugin works with Flutter Swift Package Manager integration.
- Fix duplicate XNNPack symbol linker errors when flutter litert flex is used alongside flutter litert by removing XNNPack definitions from TFLiteFlex and hiding overlapping symbols in TensorFlowLiteC via nmedit.
- Fix stale flex dedup marker in podspec that caused nmedit to be skipped on re-downloaded xcframeworks.
2.5.4 #
- Fix WASM compatibility: replace dart:io import in camera_frame.dart with flutter/foundation.dart to allow package to compile under the WASM runtime.
2.5.3 #
- prepareCameraFrameFromImage and prepareCameraFrame now auto-detect isBgra based on platform. macOS uses BGRA, Windows and Linux use RGBA. The isBgra parameter is now nullable and no longer needs to be passed manually.
2.5.2 #
- Update documentation
2.5.1 #
- Add
decodeBitmap(Uint8List bytes)free function: decodes encoded image bytes (JPEG, PNG, etc.) to aweb.ImageBitmapviacreateImageBitmap, off the main thread. - Add
WebGpuFallbackmixin: transparent WebGPU-to-WASM runtime fallback for web detector classes. ProvideswithFallback<T>()which catches GPU errors, swaps all runners to WASM viaswapToWasm(), and retries once. Apply withwith WebGpuFallback; implementactiveAcceleratorandswapToWasm(). - Both exported from
package:flutter_litert/flutter_litert.darton web.
2.5.0 #
- Add
LiteRtInterpreter, an alternative web inference path backed by Google's official LiteRT.js runtime (@litertjs/core). Selectable at construction time viaLiteRtInterpreter.fromBytes(bytes, accelerator: 'webgpu' | 'wasm'), with automatic fallback fromwebgputowasmwhen ops aren't supported by the GPU delegate.- Surface chosen to match the
Interpreterhot path used by detector packages:fromBytes,getInputTensor/getOutputTensors,runForMultipleInputs(inputs, outputs).runForMultipleInputsis async (LiteRT.jsrunreturns aPromise). - Output buffers can be supplied as
Float32List,ByteBuffer, or the legacy nestedList<List<List<double>>>shape used by tflite-js callers; the float-typed buffer paths take a single bulk copy. - Read paths use
JSFloat32Array.toDartdirectly, skipping thedataSync().dartify()round-trip. - Faster output readback in the existing tflite-js
Interpreter._tensorFromJSTensor: replacesdataSync().dartify() as List<double>+Float32List.fromList(...)with a single bulk copy viaJSTensorExtensions.dataSyncFloat32. ~25 ms / call savings on a 705k-element YOLOv8n output. - Auto-loader: by default the first
LiteRtInterpreter.fromBytes(...)call programmatically appends a<script type="module">to<head>that imports@litertjs/corefrom jsDelivr and callsloadLiteRt(...); consumers don't have to touch theirweb/index.html. Override URLs (for self-hosting / strict CSP) or disable auto-loading viaconfigureLiteRtLoader(moduleUrl: ..., wasmUrl: ..., autoLoad: ...). Existing host-page loaders that assignwindow.LiteRtand dispatch alitert-readyevent still work. - Pure additive: native and unsupported targets are unchanged; the existing tflite-js
Interpreterremains the default web runtime.
- Surface chosen to match the
2.4.1 #
- Make
camera_overlay.dartWASM-compatible on Flutter Web
2.4.0 #
- Add painter primitives
drawLandmarkMarker,drawSkeletonConnections, anddrawBoundingBoxOutlinefor reuse by detector example apps and overlay widgets. Pure Dart +dart:ui, no new dependencies.
2.3.0 #
- Add camera-overlay helpers used across detector example apps:
rotationForFrame,detectionSize,coverFitScaleOffset,barQuarterTurns, andFpsCounter. All pure Dart + Flutter SDK, no new dependencies. Lets example apps drop ~200 lines of duplicated orientation / sizing / FPS boilerplate.
2.2.2 #
- Add
prepareCameraFrameFromImage, a duck-typed wrapper aroundprepareCameraFramethat accepts aCameraImage-shaped object directly (any object exposingwidth,height,planeswithbytes/bytesPerRow/bytesPerPixel). Lets detector packages expose one-line camera-stream APIs without addingpackage:cameraas a dependency here. Pure Dart, no new dependencies.
2.2.1 #
- Add
prepareCameraFramehelper plusCameraFrame,CameraFrameConversion, andCameraFrameRotationtypes. Describes a camera frame (YUV420 or packed BGRA/RGBA) in a pure-Dart descriptor that detector packages can hand to their existing detection isolate, moving thecvtColor/rotatework off the UI thread without addingopencv_dartas a dependency here. - Add
CameraPlanetypedef (structurally identical toYuvPlane; use whichever name reads better at the call site). - Add
TensorFloat32Views(native only): capturesFloat32Listviews of anInterpreter's input/output tensors once afterallocateTensors, letting detector packages reuse the same view wrappers on every inference instead of recreating them per-call. Pure Dart, no new dependencies.
2.2.0 #
- Add
packYuv420helper for packing NV12 / NV21 / I420 camera frames into a contiguous buffer
2.1.0 #
- Minor performance/accuracy optimizations:
- Remove unnecessary rounding in
fillNHWC4D - Add direct
Float32Listfast paths for common tensor flattening shapes
- Remove unnecessary rounding in
2.0.13 #
- Fix Android JVM target mismatch: bump Java compile target to 17 to match Kotlin target set by Flutter toolchain
2.0.12 #
- Fix Android Flutter beta builds by aligning Kotlin and Java JVM targets to 11
2.0.11 #
- Fix edge case in output buffer allocation
2.0.10 #
- Update documentation
2.0.9 #
- Enable XNNPACK delegate on Android (ARM NEON SIMD acceleration in auto mode)
- Allow explicit
PerformanceConfig.xnnpack()on iOS - Initialize XNNPackDelegateOptions from native defaults (preserves QS8/QU8 quantization flags)
2.0.8 #
- Add Windows XNNPack delegate support (2-5x CPU inference speedup via SIMD)
- Add CI workflow to build Windows TFLite C DLL from source with XNNPack symbols
2.0.7 #
- Fix Android custom ops library alignment for 16 KB page-size devices
2.0.6 #
- Add useIsolateInterpreter parameter to skip nested isolate creation
2.0.5 #
- Fix native crash during repeated inference by removing unsafe output tensor writeback
2.0.4 #
- Fix macOS native crashes by disabling auto IsolateInterpreter for no-delegate interpreters.
2.0.3 #
- Fix WASM compatibility: move
dart:isolateimports behind conditional exports so web compilation path is WASM-safe
2.0.2 #
- Fix: use-after-free when interpreter reads model weights from freed buffer, transfer buffer ownership from
ModeltoInterpreter
2.0.1 #
- Add
IsolateWorkerBasefor shared isolate lifecycle management - Add
RoundRobinPoolgeneric round-robin pool utility - Add
TensorTypeenum,LandmarkMixin,listUtilsshared helpers - Add weighted NMS with spatial grid optimization to
nms() - Consolidate platform-specific byte conversion into shared implementation
- Consolidate platform-specific tensor logic (native/web/unsupported)
- Consolidate desktop library loading into
DelegateLibraryLoader - Remove dead files:
all_unsupported.dart,version.dart,flutter_litert_method_channel.dart,flutter_litert_platform_interface.dart - Fix:
Modelbuffer leak, delegate options leak, stale tensor cache
2.0.0 #
Breaking: Point.x and Point.y changed from int to double.
- Upgrade
Pointto double-precision with optionalzdepth,==/hashCode,toMap()/fromMap(),is3D - Add shared
BoundingBoxclass (4-corner Point-based, supports rotated boxes)BoundingBox.ltrb()factory for axis-aligned boxesleft/top/right/bottomconvenience getterswidth,height,center,cornerscomputed propertiestoMap()/fromMap()serialization
1.4.0 #
- Fix tensor cache bug, add shared Point class, dedup internals
1.3.1 #
- Add NaN handling to
clamp01(), returns 0.0 for NaN inputs
1.3.0 #
- Add
IsolateRpcClientandsetupIsolateHandshakefor reusable isolate request/response communication
1.2.0 #
- Add shared ML utility functions
sigmoid,sigmoidClipped,clip,clamp01,argSortDesc,median,normalizeRadians(math utilities)iouXYXY,nms(non-maximum suppression)computeLetterboxParams,computeAspectPadParams,LetterboxParams,AspectPadParams(image preprocessing)bgrBytesToRgbFloat32,bgrBytesToSignedFloat32,fillNHWC4DFromBgrBytes(image-to-tensor conversion)allocTensorShape,createOutputBuffers,zeroOutputBuffers,createNHWCTensor4D,fillNHWC4D,flattenDynamicTensor(tensor allocation)decodeDetectionOutputs,transpose2D,concat0,ensure2D,xywhToXyxy(model output decoding)postProcessDetections,Detection,decodeAndSplitOutputs(end-to-end detection post-processing with NMS)
1.1.1 #
- Fix package layout to follow Pub conventions
1.1.0 #
- Add
PerformanceConfigandPerformanceMode, - Add
InterpreterFactoryandInterpreterPool - Add
generateAnchors()andSSDAnchorOptions - Add
scaleFromLetterbox()utility for letterbox-to-original coordinate mapping
1.0.3 #
- Add
SignatureRunnerfor on-device training workflows (train,infer,get_weights,set_weightssignatures) - Add Linux FlexDelegate support via
flutter_litert_flex(Linux x86_64, built from TF 2.20.0 source). All three desktop platforms (macOS, Windows, Linux) now fully support on-device training withSELECT_TF_OPSmodels and checkpoint save/restore. - Add
Interpreter.signatureCount,signatureKeys,getSignatureKey(),getSignatureRunner() - Add
SignatureRunner.cancel(),getInputTensors(),getOutputTensors(),lastNativeInferenceDurationMicroSeconds
1.0.2 #
- Add native dylibs to SPM Package.swift
- Update Dart loading paths for SPM bundle
1.0.1 #
- Improve Custom Ops documentation
1.0.0 #
- Upgrade Linux TFLite native library from 2.9.3 to 2.20.0 (built from source via CMake + Ninja + GCC x86_64)
- First stable release:
- All platforms are on updated 2.20.0 library files, official final stable release of TFLite
- Pre-bundling works on supported native platforms: users no longer need to bundle native libraries manually as was required with
tflite_flutter - Custom ops supported, see face_detection_tflite v5.0.2
exampledirectory for a working example (the binary segmentation model selfie_segmenter.tflite uses custom ops) - Web support (experimental) functional, see pose_detection v1.0.1
web_exampledirectory for a working example
0.2.2 #
- Update dependencies
0.2.1 #
- Update documentation
0.2.0 #
- Web support (experimental)
0.1.16 #
- Register iOS pluginClass
0.1.15 #
- Add missing null check in interpreter teardown path on macOS
0.1.14 #
- Improve IsolateInterpreter shutdown reliability on iOS to prevent rare use-after-free when closing during active inference
0.1.13 #
- Add Swift Package Manager (SPM) support for iOS and macOS
0.1.12 #
- Upgrade Windows TFLite native library from 2.18.0 to 2.20.0 (built from source via CMake + Ninja + MSVC x64)
0.1.11 #
- Fix iOS: download xcframeworks at pod install time so static linking works on first build
0.1.10 #
- Fix macOS: bundle native libraries in pub package so
flutter testworks without manual setup
0.1.9 #
- Fix iOS and macOS podspec compatibility with Ruby 3.4+ (Prism parser)
0.1.8 #
- Upgrade iOS TensorFlow Lite from 2.17.0 (CocoaPods) to 2.20.0 (built from source via Bazel)
- Replace CocoaPods TensorFlowLiteSwift dependency with vendored xcframeworks (TensorFlowLiteC, Metal delegate, CoreML delegate)
- All xcframeworks support device arm64 + simulator arm64/x86_64 (Apple Silicon and Intel Macs)
0.1.7 #
- Improved documentation
0.1.6 #
- Upgrade macOS TFLite native library from 2.17.1 to 2.20.0 (latest stable, universal binary: arm64 + x86_64)
- Update all C API headers to TFLite 2.20.0
- Regenerate FFI bindings (
TfLiteOperatorCreatenow takes 4 params,TfLiteOperatorCreateWithDataremoved, newkTfLiteOutputShapeNotKnownstatus, new builtin ops) - Rebuild macOS custom ops dylib against 2.20.0
0.1.5 #
- Upgrade macOS TFLite native library from 2.11.0 to 2.17.1 (universal binary: arm64 + x86_64)
- Update all C API headers to TFLite 2.17.1 (including new
TfLiteOperatorAPI replacingTfLiteRegistrationExternal) - Regenerate FFI bindings with new APIs (SignatureRunner, TfLiteInterpreterCancel, and more)
- Rebuild macOS custom ops dylib as universal binary (arm64 + x86_64)
0.1.4 #
- Bundle
libtensorflowlite_c-win.dllfrom flutter_litert Windows plugin instead of downstream packages
0.1.3 #
- Fix Windows: build and bundle custom ops DLL (tflite_custom_ops.dll) for MediaPipe models
- Fix heap corruption crash when switching between segmentation models (custom op name string was freed prematurely)
0.1.2 #
- Fix Linux: build and bundle custom ops library (libtflite_custom_ops.so) so MediaPipe models with custom ops (e.g. selfie segmentation) work on Linux
0.1.1 #
- Update AndroidManifest.xml
0.1.0 #
- Fix IsolateInterpreter thread-safety bug causing intermittent native crashes when hardware delegates are active
0.0.1 #
- Initial release, forked from tflite_flutter_custom v1.2.5
- Rebranded to flutter_litert for LiteRT ecosystem
- All native libraries bundled automatically
- Custom ops support (MediaPipe models)
- Full platform support: Android, iOS, macOS, Windows, Linux