【发布时间】:2021-08-30 12:44:48
【问题描述】:
下面是我的原始代码在flutter 1.22.6版下运行良好,但是当我升级到flutter 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;
}
...
【问题讨论】:
标签: dart-null-safety uint8list