Flutter SDK - Initializing the SDK
Requirements
Section titled Requirements- Flutter
3.41or newer (Dart SDK^3.0.0). - An OpenReplay backend of
v1.26.0or newer. Older backends report no frames support: events are still recorded, but the screen is not.
The package has no pub dependencies — the wire protocol, batching, gzip and multipart are all implemented in Dart, and everything native goes through a single platform channel.
Installation
Section titled Installationflutter pub add openreplay
Or add it to your pubspec.yaml:
dependencies:
openreplay: ^1.0.9
Initialization
Section titled InitializationYou must pass the projectKey to start(). You can get this value from your OpenReplay dashboard under ‘Preferences > Projects’.
Adding the tracking code
Section titled Adding the tracking codeWrap your app in OpenReplayWidget, then start the tracker. The wrapper is required: it provides the repaint boundary frames are captured from, so without it nothing is recorded.
import 'package:flutter/material.dart';
import 'package:openreplay/openreplay.dart';
void main() {
runApp(const OpenReplayWidget(child: MyApp()));
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) async {
await OpenReplay.instance.start(
projectKey: 'YOUR_PROJECT_KEY',
// not required if you're using our SaaS version
serverUrl: 'https://your.instance.com/ingest',
);
});
}
@override
Widget build(BuildContext context) => MaterialApp(
// records screen transitions
navigatorObservers: [ORNavigatorObserver()],
home: const HomePage(),
);
}
start() is safe to call before the first frame — capture only begins once OpenReplayWidget has laid out.
Setting up the navigation listener
Section titled Setting up the navigation listenerAdd ORNavigatorObserver to your MaterialApp (or CupertinoApp, or any Navigator) so pushed and popped routes appear in the replay timeline:
MaterialApp(
navigatorObservers: [ORNavigatorObserver()],
// ...
)
Routes are reported by route.settings.name. Unnamed routes fall back to their position in the stack (route/2), so named routes give far more readable timelines.
Sanitize Data
Section titled Sanitize DataSee how to sanitize data in Flutter replays for more details.
Initialization Options
Section titled Initialization OptionsOptions are passed as OROptions to start():
await OpenReplay.instance.start(
projectKey: 'YOUR_PROJECT_KEY',
options: const OROptions(
logs: false,
targetLongEdge: 1080,
),
);
crashes: boolCaptures Dart errors. Native crashes still need a native reporter. Default:true.analytics: boolCaptures touches, swipes, screens and inputs. Default:true.performances: boolCaptures CPU, memory, battery and thermal state. Default:true.logs: boolCapturesdebugPrintoutput. Default:true.screen: boolEnables frame capture. Default:true.screenshotBatchSize: ScreenshotBatchSizeFrames buffered before a batch is packed and uploaded —low(10),normal(20) orhigh(30). Default:normal.targetLongEdge: intLongest edge of a captured frame, in pixels. Caps per-frame cost so it does not swing with screen size. Default:720.dedupeFrames: boolSkips frames whose pixels are byte-identical to the previous one. Playback is unaffected — the player holds the last snapshot at or before the current time. Default:true.maskPlatformViews: boolCovers platform views (WebView, maps, camera preview) with a placeholder. They render in native layers Flutter cannot read back, so without this they appear blank. Default:true.wifiOnly: boolReserved; not yet enforced. Default:true.debugLogs: boolEnables the SDK’s own logging. Default:false.debugImages: boolDumps captured frames for debugging. Default:false.
Two presets are provided: OROptions.defaults (all of the above) and OROptions.defaultDebug (the same, with debugLogs: true).
Server URL
Section titled Server URLserverUrl defaults to OpenReplay Cloud. Self-hosted deployments pass it to start(), or set it ahead of time:
OpenReplay.instance.serverUrl = 'https://your.instance.com/ingest';
Modules
Section titled ModulesMethods
Section titled MethodsHave questions?
Section titled Have questions?If you have any questions about this process, feel free to reach out to us on our Slack or check out our Forum.