firebase_testlab_detector

A Flutter plugin for Android that helps determine if your app is running within Firebase Test Lab. Use this to differentiate between regular usage and test runs in Firebase Test Lab (i.e., during Google Play pre-launch reports).

Only works on Android. Returns null on other platforms. Version 3.x requires Flutter 3.47 or newer and Android API 24 or newer. Android builds require Java 17 or newer and AGP 9 with built-in Kotlin support. Existing apps must follow Flutter's built-in Kotlin migration, including removing the legacy Kotlin Android plugin.

Getting Started

1. Add the dependency

Flutter 3.47+

dependencies:
  firebase_testlab_detector: ^3.0.1

Flutter 3.10–<3.47

dependencies:
  firebase_testlab_detector: ^2.0.0

2. Use the plugin

import 'package:firebase_testlab_detector/firebase_testlab_detector.dart';

Future<bool> runningInTestLab() async {
  return await FirebaseTestlabDetector.isAppRunningInTestlab() ?? false;
}

Call from an initialized Flutter application. If you check before runApp, first call WidgetsFlutterBinding.ensureInitialized() from package:flutter/widgets.dart.

This plugin reads the Android Settings.System setting firebase.test.lab, and returns a boolean value indicating whether the app is running in Firebase Test Lab.

See also the Firebase documentation for more details.

Native lookup failures propagate as PlatformException; missing plugin registration throws MissingPluginException. The example falls back to false for either error.

Why use this plugin?

You might want to utilize this plugin to disable analytics, preventing skewed data from Firebase Test Lab (i.e., Google Play pre launch report) from appearing in your analytics dashboard.

Development

Install FVM, then install the stable Flutter SDK selected by the repository's .fvmrc. Run the complete local checks, including Dart, Flutter, Android integration, native plugin, and debug-build checks, with an Android device or emulator.

fvm install -s
./tool/check.sh <android-device-id>