isValidFile method
Is the given file a valid PNG image?
Implementation
@override
bool isValidFile(List<int> data) {
final input = InputBuffer(data, bigEndian: true);
final pngHeader = input.readBytes(8);
const PNG_HEADER = [137, 80, 78, 71, 13, 10, 26, 10];
for (var i = 0; i < 8; ++i) {
if (pngHeader[i] != PNG_HEADER[i]) {
return false;
}
}
return true;
}