webGoldenComparator top-level property

WebGoldenComparator webGoldenComparator

Compares pixels against those of a golden image file.

This comparator is used as the backend for matchesGoldenFile when tests are running in a web browser.

When using flutter test --platform=chrome, a comparator implemented by DefaultWebGoldenComparator is used if no other comparator is specified. It will send a request to the test server, which uses goldenFileComparator for golden file comparison.

When using flutter test --update-goldens, the DefaultWebGoldenComparator updates the files on disk to match the rendering.

When using flutter run, the default comparator (_TrivialWebGoldenComparator) is used. It prints a message to the console but otherwise does nothing. This allows tests to be developed visually on a web browser.

Callers may choose to override the default comparator by setting this to a custom comparator during test set-up (or using directory-level test configuration). For example, some projects may wish to install a comparator with tolerance levels for allowable differences.

See also:

  • flutter_test for more information about how to configure tests at the directory-level.
  • goldenFileComparator, the comparator used when tests are not running on a web browser.

Implementation

WebGoldenComparator get webGoldenComparator => _webGoldenComparator;
void webGoldenComparator=(WebGoldenComparator value)

Implementation

set webGoldenComparator(WebGoldenComparator value) {
  _webGoldenComparator = value;
}