asBytes method
Generate png as a list of ints from seed value
Implementation
Future<List<int>> asBytes(int seed) async {
var cache = pngCache[seed];
if (cache != null) {
return cache;
}
var image = await draw(seed);
if (image != null) {
return pngCache[seed] = img.encodePng(image, level: 0);
}
// return 1x1 transparent image as fallback
return base64
.decode(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=")
.toList();
}