Below is my original codes run well without problem under flutter version 1.22.6, however when I upgraded to flutter version 2.2.1 error of "The argument type 'List' can't be assigned to the parameter type 'Uint8List'." flagged with red error:
final paint = await PaintingBinding.instance! .instantiateImageCodec(asset != null ? img.encodePng(asset) : buffer);
Anyone could help will be much appreaciated.
This my code:
Future<BeautifulPopup> recolor(Color color) async {
primaryColor = color;
final illustrationData = await rootBundle.load(instance.illustrationKey);
final buffer = illustrationData.buffer.asUint8List();
img.Image asset;
asset = img.readPng(buffer)!;
img.adjustColor(
asset,
saturation: 0,
// hue: 0,
);
img.colorOffset(
asset,
red: primaryColor.red,
// I don't know why the effect is nicer with the number ╮(╯▽╰)╭
green: primaryColor.green ~/ 3,
blue: primaryColor.blue ~/ 2,
alpha: 0,
);
final paint = await PaintingBinding.instance!
.instantiateImageCodec(asset != null ? img.encodePng(asset) : buffer);
final nextFrame = await paint.getNextFrame();
_illustration = nextFrame.image;
return this;
}
...