matchAsync method
Returns null if this matches item, or a String description of the
failure if it doesn't match.
This can return a Future or a synchronous value. If it returns a
Future, neither expect nor the test will complete until that Future
completes.
If this returns a String synchronously, expect will synchronously
throw a TestFailure and matches will synchronously return false.
Implementation
@override
Future<String?> matchAsync(dynamic item) async {
// Cache the current goldenFileComparator so we can restore
// it after the test.
final originalComparator = goldenFileComparator;
try {
goldenFileComparator = PixelDiffGoldenComparator(
(goldenFileComparator as LocalFileComparator).basedir.path,
pixelCount: _maxPixelMismatchCount,
);
return await super.matchAsync(item);
} finally {
goldenFileComparator = originalComparator;
}
}