Skip to content

Mobile integration

Flutter Session Replay SDK: Add It to Your App

Add session replay to a Flutter app with anyreplay_flutter: install, init, screen names, on-device masking, consent and known limits. No screenshots are taken.

Updated · 4 min read

To add session replay to a Flutter app, add the anyreplay_flutter package, call AnyReplay.init before runApp and give your app an AnyReplayNavigatorObserver. The package runs on Android and iOS with Flutter 3.27 or later and has no native code of its own. It records the screen as a tree of boxes and words read from Flutter itself, and never takes a screenshot.

This page is the install path. For what the recorder reads and why the replay is a wireframe rather than video, read session replay for Flutter.

Why add session replay to a Flutter app

A crash report tells you where the code stopped. It does not tell you that the person tapped Pay three times, went back, changed the delivery address and gave up. A recording shows the screens they moved through, where they tapped and what the app showed them at each step. AnyReplay records what each widget is and what it says, so a replay is boxes in the right places with the real words in them. That keeps recordings small and lets a reviewer translate a session into the language they read.

Requirements

  • Flutter 3.27 or later, on Android and iOS.
  • No native code of its own: the package uses shared_preferences, package_info_plus and device_info_plus.
  • If the project lists allowed domains, add the app's bundle id (iOS) or package name (Android) under Allowed apps. The SDK reads it from the app and sends it.

How to install the Flutter session replay SDK

flutter pub add anyreplay_flutter

The package brings plugins with native code, so stop the app and start it again with flutter run after adding it. A hot reload or hot restart does not load them.

import 'package:anyreplay_flutter/anyreplay_flutter.dart';
import 'package:flutter/material.dart';

// The app id (bundle id / package name) is read from the app itself.
void main() {
  AnyReplay.init(const AnyReplayOptions(
    projectKey: 'YOUR_PROJECT_KEY',
    ingestUrl: 'https://in.anyreplay.com',
    // Stop recording after this many sessions in a calendar month.
    // maxSessionsPerMonth: 10000,
    // Fields are masked: what people type replays as asterisks. Secure
    // fields, passwords, one-time codes and card fields are masked either
    // way. Uncomment the first line to record what people type, or the
    // second to mask every field in a way nothing can weaken.
    // maskAllInputs: false,
    // maskAllTyping: true
  ));
  runApp(MaterialApp(
    navigatorObservers: [AnyReplayNavigatorObserver()],
    home: const HomeScreen(),
  ));
}
lib/main.dart, as shown in the dashboard's Flutter tab
  • AnyReplay.init(options) starts the recorder. Taps, errors and the app lifecycle are picked up on their own, and the app id and version are read from the app.
  • AnyReplayNavigatorObserver names each screen after its route. It works with Navigator and with go_router.

Are screen changes recorded?

Yes, when routes have names. The observer reads RouteSettings.name and cuts off any query string or fragment. Name routes by what they are, such as /orders/:id, never by who is looking, such as /orders/829461, because screen names are not masked. Dialogs, bottom sheets and menus are layers of the screen they open over, not screens of their own. For routes without a name, pass nameOf: to the observer or call AnyReplay.screen('Checkout') from your own navigation code.

GoRouter(observers: [AnyReplayNavigatorObserver()], routes: [...]);

How do I keep sensitive data out of recordings?

  • What people type into a text field is masked by default, as it is on the web. Set maskAllInputs: false to record typing, or maskAllTyping: true for masking that no other option can weaken.
  • Masked whatever you configure: a field with obscureText: true, any field whose autofillHints, keyboard type, hint, label or string Key marks it as a password, one-time code or payment field, and any card number, whole or typed past its sixth digit.
  • Wrap a widget in AnyReplayMask to mask it and everything inside it.
  • Set maskImages: true to record no image addresses and upload no bundled images.
  • Pass requireConsent: true and call AnyReplay.consent(true) when the person agrees. Until then nothing is stored, sent or read. AnyReplay.consent(false) stops recording and deletes what AnyReplay stored on the device.
AnyReplayMask(child: Text(order.deliveryAddress))

A masked element keeps its box and loses its words, on the device, before anything is sent. One limit is worth stating plainly: with maskAllInputs: false, a TextField() with no hints says nothing about itself, so it is recorded, and only the card-number check on its value can catch it. Give sensitive fields autofillHints, wrap them in AnyReplayMask, or keep the default. See masking and blocking and consent.

Known limits

  • A CustomPainter, a chart library that paints or a game records as an opaque box with its Semantics label. Wrap one in Semantics(label: …) to give it a name.
  • Web views, maps and videos replay as labelled boxes; their contents are not recorded.
  • Icons from your own icon fonts record as an icon without a name, and images inside decorations as their box.
  • A multi-window or multi-view app is recorded from its first view.
  • An --obfuscate build cannot recognise web views, maps or video players by name, so they fall back to opaque boxes.

How do I check it is working?

  1. Pass debug: true to AnyReplayOptions and watch the console for lines prefixed [anyreplay].
  2. Open the app, move between two screens, then send it to the background to flush the buffer.
  3. Find the session under Sessions in the dashboard. If requests are refused, the app's id is missing from Allowed apps.

Taps on each screen are drawn as a tap map; see heatmaps. The Flutter install guide has every option and the answers the App Store and Google Play ask for. Building with React Native instead? See session replay for React Native.

Frequently asked questions

Does the Flutter SDK take screenshots?

No, and there is no screenshot fallback. The screen is read as a tree of boxes and words; anything that cannot be read as words, such as a custom painter, a web view, a map or a video, is recorded as a labelled box.

Which platforms does it support?

Android and iOS, with Flutter 3.27 or later. The package is on pub.dev as `anyreplay_flutter` and is MIT-licensed.

Does it work with go_router?

Yes. Pass `AnyReplayNavigatorObserver()` in the router's `observers`, and each screen is named after its route.

Does it break my crash reporter?

No. AnyReplay records uncaught errors by installing `FlutterError.onError` and `PlatformDispatcher.onError`, always calls the handlers that were there before, and puts them back when recording stops.

How much does it send?

The first frame of a screen is a few kilobytes, and every frame after it carries only what changed. A screen that does not change sends nothing. The screen is read every 500 ms, between frames.

Start free — 2 projects, 15,000 sessions a month

Install the snippet, record a session, and watch it back in your own language.