Flutter SDK (Android)

Native Android telemetry via MethodChannel, targeting the same com.teleneura.sdk:shared library consumed by the React Native bridge. Latency samples batch on-device; HTTPS runs in Kotlin — Dart forwards primitives only.

Class names: If your generated plugin still exposes YasmoFlutterSdk and the package yasmo_flutter_sdk, use those identifiers — method names (initialize, reportInference, flush) match this guide.


Pub dependency

Add the plugin from your monorepo (path relative to your Flutter app):

dependencies:
  flutter:
    sdk: flutter
  teleneura_flutter_sdk:
    path: ../packages/teleneura_flutter_sdk

If your repository still uses the legacy package name (yasmo_flutter_sdk), keep that dependency key — the integration steps below are otherwise identical after adjusting imports.


Android · Maven Local

Publish the shared artifact:

cd packages/teleneura-sdk-KMP && ./gradlew :shared:publishToMavenLocal

The plugin’s android/build.gradle.kts should declare:

implementation("com.teleneura.sdk:shared:1.0.0-local")

Ensure mavenLocal() appears in your Flutter Android host (settings.gradle / repository blocks). Align Kotlin with the published SDK (typically 2.3.x).


Usage

Call initialize once after WidgetsFlutterBinding.ensureInitialized(). Wrap each inference with reportInference. Use flush on lifecycle boundaries when you need immediate upload.

import 'dart:developer' as developer;
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:tflite_flutter/tflite_flutter.dart';
import 'package:teleneura_flutter_sdk/teleneura_flutter_sdk.dart';

late final Interpreter _interpreter;
final TeleneuraFlutterSdk _telemetry = TeleneuraFlutterSdk();

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  try {
    await _telemetry.initialize(
      apiKey: const String.fromEnvironment('TELENEURA_API_KEY'),
      baseUrl: const String.fromEnvironment('TELENEURA_BASE_URL'),
      batchSize: 32,
      enableDebugLogs: kDebugMode,
    );
  } on PlatformException catch (e, st) {
    developer.log('Teleneura init failed', error: e, stackTrace: st);
  }

  _interpreter = await Interpreter.fromAsset('models/detector.tflite');
  runApp(const MyApp());
}

Future<List<double>> runDetector(Float32List input) async {
  final sw = Stopwatch()..start();

  final output = List.filled(1 * 10, 0.0).reshape([1, 10]);
  _interpreter.run(input.buffer.asUint8List(), output);

  sw.stop();
  _telemetry.reportInference('detector.tflite', sw.elapsedMilliseconds.toDouble());

  return List<double>.from(output[0] as List);
}

Future<void> disposeTelemetry() async {
  await _telemetry.flush();
}

If your plugin class is still named YasmoFlutterSdk, substitute it for TeleneuraFlutterSdk above.


API surface

Method

Role

initialize ( apiKey, baseUrl, batchSize, enableDebugLogs)

Configure ingestion; throws PlatformException with E_CONFIG / E_INIT on failure.

reportInference(modelName, latencyMs)

Fire-and-forget native batching.
flush()Flush buffered batches.

iOS: unimplemented until you ship a native Swift counterpart (MissingPluginException).