Skip to content

Commit 622d859

Browse files
committed
fix dart2js tests
1 parent e7ab100 commit 622d859

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

flutter/lib/src/screenshot/screenshot.dart

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,27 @@ class Screenshot {
7272
/// For now, the best we can do is compare by chunks of 8 bytes.
7373
// return 0 == memcmp(dataA.address, dataB.address, dataA.lengthInBytes);
7474

75-
final numWords = dataA.lengthInBytes ~/ 8;
76-
final wordsA = dataA.buffer.asUint64List(0, numWords);
77-
final wordsB = dataB.buffer.asUint64List(0, numWords);
78-
79-
for (var i = 0; i < wordsA.length; i++) {
80-
if (wordsA[i] != wordsB[i]) {
81-
return false;
75+
late final int processed;
76+
try {
77+
final numWords = dataA.lengthInBytes ~/ 8;
78+
final wordsA = dataA.buffer.asUint64List(0, numWords);
79+
final wordsB = dataB.buffer.asUint64List(0, numWords);
80+
81+
for (var i = 0; i < wordsA.length; i++) {
82+
if (wordsA[i] != wordsB[i]) {
83+
return false;
84+
}
8285
}
86+
processed = wordsA.lengthInBytes;
87+
} on UnsupportedError {
88+
// This should only trigger on dart2js:
89+
// Unsupported operation: Uint64List not supported by dart2js.
90+
processed = 0;
8391
}
8492

8593
// Compare any remaining bytes.
86-
final bytesA = dataA.buffer.asUint8List(wordsA.lengthInBytes);
87-
final bytesB = dataB.buffer.asUint8List(wordsA.lengthInBytes);
94+
final bytesA = dataA.buffer.asUint8List(processed);
95+
final bytesB = dataB.buffer.asUint8List(processed);
8896
for (var i = 0; i < bytesA.lengthInBytes; i++) {
8997
if (bytesA[i] != bytesB[i]) {
9098
return false;

0 commit comments

Comments
 (0)