下面是我的原始代码在颤振版本 1.22.6 下运行良好,但是当我升级到颤振版本 2.2.1 时出现“无法将参数类型'List'分配给参数类型'Uint8List'”的错误。标记为红色错误:
最终油漆 = 等待 PaintingBinding.instance!.instantiateImageCodec(asset != null ? img.encodePng(asset) : buffer);
任何人都可以提供帮助将不胜感激。
这是我的代码:
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;
}
...