Setup
Set up ZETIC Melange in your Flutter project.
This guide targets zetic_mlange 1.8.1 — the Flutter FFI SDK for Android and iOS.
This guide walks you through adding the ZETIC Melange Flutter SDK to your app. The Flutter package exposes a Dart API and delegates model loading, cache management, and execution to the Android and iOS SDKs through FFI.
Prerequisites
- Flutter 3.35.0 or later
- Dart 3.11.5 or later
- A physical Android or iOS device
- A Personal Key from the Melange Dashboard
- A compiled model on the Melange Dashboard, identified by
account_name/project_name
Emulators and simulators do not provide the same NPU hardware as physical devices. Use a real device for inference and performance testing.
Add Melange Dependency
Add the Flutter package to your app:
dependencies:
zetic_mlange: ^1.8.1Then fetch packages:
flutter pub getConfigure Android
Set Android minSdk to 24 or later, build for arm64-v8a, and enable legacy JNI packaging in your app module.
android/app/build.gradle.kts
android {
defaultConfig {
minSdk = maxOf(flutter.minSdkVersion, 24)
ndk {
abiFilters += "arm64-v8a"
}
}
packaging {
jniLibs {
useLegacyPackaging = true
}
}
}useLegacyPackaging is required so native model runtime libraries are packaged in a form Android can load at runtime. Without it, Android may fail with UnsatisfiedLinkError when the FFI layer loads native runtime libraries.
Configure iOS
Set the iOS deployment target to 16.6 or later. The Flutter pod downloads and links the ZeticMLange.xcframework release and Apple's Accelerate framework through CocoaPods.
ios/Podfile
platform :ios, '16.6'
target 'Runner' do
use_frameworks!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
endThen install pods:
cd ios
pod installThe Flutter SDK uses the published iOS framework release. You do not need to copy a local ZeticMLange.xcframework into the Flutter package before running pod install.
Verify Setup
Import the package and create a model:
import 'package:zetic_mlange/zetic_mlange.dart';
final model = await ZeticMLangeModel.create(
personalKey: personalKey,
name: 'account_name/project_name',
onProgress: (progress) {
print('Loading ${(progress * 100).round()}%');
},
);If the model initializes without an exception, your Flutter setup is ready.
Model creation downloads the optimized model artifact on first use. Run it outside latency-sensitive UI paths and show progress with onProgress when needed.