scenarioPlaceholderPng function
A solid PNG, for a scenario that needs an image to be there and does not care what it is.
The alternative in a test file is a base64 blob nobody can read or change, pasted once and copied forever.
Implementation
Uint8List scenarioPlaceholderPng({
int width = 1,
int height = 1,
int red = 0x9E,
int green = 0x9E,
int blue = 0x9E,
}) {
var raw = BytesBuilder();
for (var y = 0; y < height; y++) {
raw.addByte(0);
for (var x = 0; x < width; x++) {
raw.add([red, green, blue]);
}
}
var ihdr = BytesBuilder()
..add(_be32(width))
..add(_be32(height))
..add([8, 2, 0, 0, 0]);
return Uint8List.fromList([
0x89,
0x50,
0x4E,
0x47,
0x0D,
0x0A,
0x1A,
0x0A,
..._chunk('IHDR', ihdr.toBytes()),
..._chunk('IDAT', ZLibEncoder().convert(raw.toBytes())),
..._chunk('IEND', const []),
]);
}