FlutterFever Studio
Back to packages

Tracera Flutter package guide

A lightweight adapter that brings Tracera Autotest capabilities to Flutter widget and integration tests.

Install command
Copy and run in your Flutter project
flutter pub add tracera_flutter

When to use Tracera Flutter

Tracera Flutter is a purpose‑built testing helper that bridges the gap between Flutter's native testing framework and the Tracera Autotest platform. By adding a thin layer of bindings, it enables developers to capture detailed test steps, lifecycle events, screenshots, and custom attachments without rewriting existing test logic. The package works with both unit‑style widget tests and full‑blown integration tests, allowing you to keep a single source of truth for test artefacts while still leveraging Flutter's fast test runner.

When you are building a medium‑to‑large Flutter application, maintaining reliable UI tests becomes a strategic investment. Tracera Flutter shines in scenarios where you need traceability across CI pipelines, visual regression evidence, or when you want to enrich test reports with contextual data such as device logs or network payloads. Instead of scattering `await expectLater` calls throughout your test suite, you wrap test sections with Tracera's `step` API, which automatically records timestamps, screenshots, and any attached files you provide. This structured output feeds directly into Tracera's dashboard, where stakeholders can review test runs, compare builds, and pinpoint flaky areas.

Architecturally, Tracera Flutter sits at the outermost layer of your testing stack. It does not interfere with state‑management choices (Provider, Riverpod, Bloc, etc.) or architectural patterns (Clean, MVVM, Redux). The package simply observes the Flutter test harness, intercepts the widget tree when a step begins, and triggers a screenshot using the `flutter_test` engine. Because it respects null‑safety and works with Flutter 3.0+, you can adopt it in any modern codebase without worrying about version drift. The only requirement is that your test environment runs on a platform that supports screenshot capture – typically Android, iOS simulators, or Chrome for web tests.

Getting started is straightforward. After adding the dependency, you import the library in your test file, initialize the Tracera client with your project key, and wrap test bodies with `TraceraTestGroup` or `TraceraStep`. The API mirrors the familiar `testWidgets` syntax, so there is little learning curve. For example, a simple widget test can record a step, take a screenshot, and attach a JSON payload that describes the UI state. All artefacts are uploaded asynchronously to Tracera's cloud, where they become searchable by build number, test name, or tag. This approach eliminates the manual effort of zipping screenshots and logs after each CI run.

In production environments, be mindful of the additional network overhead introduced by uploading artefacts. While the package batches uploads to minimise impact, you may want to disable it for local development or for very large test suites by toggling the `enabled` flag. Also, remember that screenshots capture the exact pixel dimensions of the device under test; if you run tests across multiple screen sizes, you will receive a richer visual matrix but also larger storage consumption. Finally, because Tracera Flutter does not alter the execution of your tests, existing flaky tests remain flaky – the package only provides better diagnostics to help you fix them.

For beginners, Tracera Flutter offers a low‑friction entry point into advanced test reporting. You can start by adding a single step to an existing widget test and instantly see a screenshot appear in the Tracera UI. As you grow more comfortable, you can enrich steps with custom attachments, group related steps into logical sections, and even integrate with CI tools like GitHub Actions or GitLab CI to automatically publish test runs on every pull request. The package’s clear documentation, concise API, and compatibility with all major Flutter platforms make it an excellent addition to any test‑driven development workflow.

widget testing with visual evidence
integration testing across platforms
CI pipelines that need detailed test artefacts
debugging flaky UI tests
regression testing with screenshot comparison

Pros

  • adds rich reporting without changing test logic
  • supports screenshots and custom attachments
  • works with all major Flutter platforms
  • null‑safe and lightweight

Watch outs

  • adds network overhead for artefact upload
  • requires Tracera account and project key
  • screenshots only work on platforms that support them

Setup notes

Add the dependency with the following command: ``` flutter pub add tracera_flutter ``` Then run `flutter pub get`. Import the package in your test files and initialize the client with your Tracera project key before writing tests.

Requires Flutter 3.0 or higher and Dart SDK >=2.17. The package is null‑safe and works on Android, iOS, web (Chrome), macOS, and Windows test environments that support screenshot capture.

import 'package:flutter_test/flutter_test.dart';
import 'package:tracera_flutter/tracera_flutter.dart';

void main() {
  final tracera = TraceraClient(projectKey: 'YOUR_PROJECT_KEY');

  testWidgets('login screen renders correctly', (WidgetTester tester) async {
    await tracera.step('build login widget', () async {
      await tester.pumpWidget(const MyApp());
    });

    await tracera.step('verify email field', () async {
      expect(find.byKey(const Key('email')), findsOneWidget);
    });

    await tracera.attach('login_state.json', '{"loggedIn": false}');
  });
}

Official package resources