golden_matrix 1.0.0 copy "golden_matrix: ^1.0.0" to clipboard
golden_matrix: ^1.0.0 copied to clipboard

Matrix-based golden testing for Flutter. Declare themes, locales, devices, text scales and get all combinations with sampling, HTML reports, overflow detection.

golden_matrix

golden_matrix #

pub package test codecov

Matrix-based visual regression testing for Flutter. Declare themes, locales, devices, text scales โ€” get all combinations, sampled if you want, with HTML + JUnit reports for CI.

๐Ÿ“– Docs ยท Quick start ยท CI integration ยท Migrating from golden_toolkit

Install #

# pubspec.yaml
dev_dependencies:
  golden_matrix: ^1.0.0
// test/flutter_test_config.dart โ€” load real fonts for text rendering
import 'dart:async';
import 'package:golden_matrix/golden_matrix.dart';

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
  await loadAppFonts();
  return testMain();
}

30-second example #

import 'package:flutter/widgets.dart';
import 'package:golden_matrix/golden_matrix.dart';

void main() {
  matrixGolden(
    'PrimaryButton',
    scenarios: [
      MatrixScenario('default', builder: () => const PrimaryButton(label: 'OK')),
      MatrixScenario('disabled', builder: () => const PrimaryButton(label: 'OK', enabled: false)),
    ],
    axes: MatrixAxes(
      themes: [MatrixTheme.light, MatrixTheme.dark],
      locales: [Locale('en'), Locale('ar')],
      textScales: [1.0, 2.0],
      devices: [MatrixDevice.phoneSmall, MatrixDevice.phoneLarge],
    ),
  );
  // 2 scenarios ร— 2 themes ร— 2 locales ร— 2 scales ร— 2 devices = 32 golden files
}
flutter test --update-goldens  # generate baselines
flutter test                   # run regression tests

What's in the box #

  • Declarative matrix โ€” themes ร— locales ร— devices ร— text scales ร— directions, all combinations automatically
  • Three entry points โ€” matrixGolden (components), screenMatrixGolden (full screens), componentMatrixGolden (intrinsic-size primitives)
  • Sampling โ€” full, smoke, pairwise, priorityBased to keep CI fast
  • HTML / JSON / Markdown / JUnit XML reports โ€” with inline pixel-diff thumbnails on failure
  • Stale + overflow detection โ€” orphan goldens and RenderFlex overflow surface automatically
  • RTL auto-inference for Arabic / Hebrew / Farsi
  • 20+ device presets โ€” modern iPhones, Android, foldables, full iPad lineup, plus custom devices
  • DI-friendly โ€” wrapApp / wrapChild hooks for Riverpod / Bloc / Provider
  • Dry-run preview โ€” inspect counts, paths, and collisions without rendering
  • Zero external dependencies โ€” only the Flutter SDK

Read the full docs โ†’

Requirements #

  • Flutter SDK >= 3.16.0
  • Dart SDK >= 3.2.0

License #

MIT

3
likes
0
points
692
downloads

Publisher

verified publishermavoryl.com

Weekly Downloads

Matrix-based golden testing for Flutter. Declare themes, locales, devices, text scales and get all combinations with sampling, HTML reports, overflow detection.

Repository (GitHub)
View/report issues

Topics

#testing #golden-tests #widget-testing #visual-regression #snapshot-testing

License

unknown (license)

Dependencies

flutter, flutter_localizations, flutter_test

More

Packages that depend on golden_matrix