Skip to content

Commit

Permalink
fix dart2js tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Jan 10, 2025
1 parent e7ab100 commit 622d859
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions flutter/lib/src/screenshot/screenshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,27 @@ class Screenshot {
/// For now, the best we can do is compare by chunks of 8 bytes.
// return 0 == memcmp(dataA.address, dataB.address, dataA.lengthInBytes);

final numWords = dataA.lengthInBytes ~/ 8;
final wordsA = dataA.buffer.asUint64List(0, numWords);
final wordsB = dataB.buffer.asUint64List(0, numWords);

for (var i = 0; i < wordsA.length; i++) {
if (wordsA[i] != wordsB[i]) {
return false;
late final int processed;
try {
final numWords = dataA.lengthInBytes ~/ 8;
final wordsA = dataA.buffer.asUint64List(0, numWords);
final wordsB = dataB.buffer.asUint64List(0, numWords);

for (var i = 0; i < wordsA.length; i++) {
if (wordsA[i] != wordsB[i]) {
return false;
}
}
processed = wordsA.lengthInBytes;
} on UnsupportedError {
// This should only trigger on dart2js:
// Unsupported operation: Uint64List not supported by dart2js.
processed = 0;
}

// Compare any remaining bytes.
final bytesA = dataA.buffer.asUint8List(wordsA.lengthInBytes);
final bytesB = dataB.buffer.asUint8List(wordsA.lengthInBytes);
final bytesA = dataA.buffer.asUint8List(processed);
final bytesB = dataB.buffer.asUint8List(processed);
for (var i = 0; i < bytesA.lengthInBytes; i++) {
if (bytesA[i] != bytesB[i]) {
return false;
Expand Down

0 comments on commit 622d859

Please sign in to comment.