Skip to content

Commit 11e5d3d

Browse files
committed
Update the golden image comparator to handle read-only image ByteData views
The engine is now wrapping image byte data in an UnmodifiableByteDataView (see flutter/engine#19504). The golden image comparator must make a copy before modifying the buffer.
1 parent bb32808 commit 11e5d3d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/flutter_test/lib/src/_goldens_io.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ Future<ComparisonResult> compareLists(List<int> test, List<int> master) async {
210210
final ByteData invertedMasterRgba = _invert(masterImageRgba);
211211
final ByteData invertedTestRgba = _invert(testImageRgba);
212212

213-
final ByteData maskedDiffRgba = await testImage.toByteData();
213+
final Uint8List testImageBytes = (await testImage.toByteData()).buffer.asUint8List();
214+
final ByteData maskedDiffRgba = ByteData(testImageBytes.length);
215+
maskedDiffRgba.buffer.asUint8List().setRange(0, testImageBytes.length, testImageBytes);
214216
final ByteData isolatedDiffRgba = ByteData(width * height * 4);
215217

216218
for (int x = 0; x < width; x++) {

0 commit comments

Comments
 (0)