Install on Flutter
Use the Flutter SDK when your product is a Flutter app on iOS or Android. It is a pure Dart package published on pub.dev, with no native code of its own. Enable Mobile apps traffic during Create your first property before sending events.
Install
flutter pub add nexly
Initialize
Wrap the root widget in NexlyProvider:
import 'package:nexly/nexly.dart';
void main() {
runApp(NexlyProvider(
appId: 'your-app-id',
ingestKey: 'your-ingest-key',
child: const MyApp(),
));
}
Or initialize manually before runApp:
WidgetsFlutterBinding.ensureInitialized();
await Nexly.init(appId: 'your-app-id', key: 'your-ingest-key');
Use the App ID and Ingest key from Settings → Installation. Do not use a personal API token for SDK collection.
Track screens and events
Send a screenview when the visible screen changes:
Nexly.screenview('Settings');
Emit custom events from anywhere in the app:
ElevatedButton(
onPressed: () => Nexly.customEvent('checkout_started', cdata: {'cart_value_cents': 4200}),
child: const Text('Checkout'),
)
Engagement tracking (active seconds, heartbeats, session end) is driven automatically by app lifecycle callbacks, matching the React Native and Swift SDKs' behavior.
Privacy mode and identity
The Flutter SDK supports the same privacy mode as the other SDKs: when enabled, it never reads or writes on-device storage for the visitor and session IDs. Like the Swift SDK, it can be toggled at runtime — useful for a consent switch in your settings screen:
await Nexly.setPrivacyMode(true);
You can also override the visitor or session ID, for example to link app events to an identity your backend already knows:
Nexly.setVisitorId('your-visitor-id');
Nexly.setSessionId('your-session-id');
Changes take effect on the next event; no reinitialization is needed.
Allowed origins
Flutter traffic uses a dedicated SDK traffic source instead of a browser origin. Enable Mobile apps in Settings → Ingest so the collector accepts events from the SDK. See Ingest settings for details.
Verification
Use the events feed to confirm events arrive with the Flutter (iOS) or Flutter (Android) source. The Technology widget shows Flutter traffic as browser Flutter on iOS or Android mobile devices.