Skip to main content

Flutter wrapper

An env-gated telemetry bootstrap and a navigator observer over the Dart client. It does nothing unless a host and a public key are both present.

Where it is published

prodantix_sdk_flutter on pub.dev. It wraps prodantix_sdk.

Install

Bash
flutter pub add prodantix_sdk_flutter

Gated on the environment

fromEnv returns a working client only when a host and a public key are both present and the key has the right shape. Anything else returns a silent no-op, so an app ships identically without ingest credentials, and a malformed key is reported through onError instead of crashing at boot.

Dart
import 'package:prodantix_sdk_flutter/prodantix_sdk_flutter.dart';

final telemetry = Telemetry.fromEnv(
  host: const String.fromEnvironment('PRODANTIX_HOST'),
  key: const String.fromEnvironment('PRODANTIX_PUBLIC_KEY'),
  onError: (error) => debugPrint('prodantix: $error'),
);

telemetry.identify('user-123');
telemetry.track('app.opened', properties: {'source': 'cold_start'});

await telemetry.shutdown();

Screen tracking

Add the observer to your navigator and every pushed or replaced route reports a screen event, which mirrors the pageview autocapture of the web SDK. Routes with no name are skipped.

Dart
MaterialApp(
  navigatorObservers: [TelemetryRouteObserver(telemetry)],
  home: const HomePage(),
);

// Or, with go_router:
GoRouter(
  observers: [TelemetryRouteObserver(telemetry)],
  routes: routes,
);
This package depends on prodantix_sdk by version range rather than by path, because pub.dev refuses a package carrying a path dependency. The Dart client therefore has to reach pub.dev before this one can.