golden_matrix
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: ^0.19.2
// 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,priorityBasedto keep CI fast - HTML / JSON / Markdown / JUnit XML reports โ with inline pixel-diff thumbnails on failure
- Stale + overflow detection โ orphan goldens and
RenderFlex overflowsurface automatically - RTL auto-inference for Arabic / Hebrew / Farsi
- 20+ device presets โ modern iPhones, Android, foldables, full iPad lineup, plus custom devices
- DI-friendly โ
wrapApp/wrapChildhooks for Riverpod / Bloc / Provider - Dry-run preview โ inspect counts, paths, and collisions without rendering
- Zero external dependencies โ only the Flutter SDK
Requirements
- Flutter SDK >= 3.16.0
- Dart SDK >= 3.2.0
License
MIT