[英]Error on printing our Images on Receipt via POS system
Here is my code below.下面是我的代码。
Future<List<int>> getImage() async {
List<int> bytes = [];
CapabilityProfile profile = await CapabilityProfile.load();
final generator = Generator(PaperSize.mm80, profile);
final ByteData data = await rootBundle.load('assets/logo.png');
final buffer = data.buffer;
final image = base64.encode(Uint8List.view(buffer));
bytes += generator.image(image);
return bytes;
}
At在
bytes += generator.image(image);
the error said that错误说
Error: The argument type 'String' can't be assigned to the parameter type 'Image'.
错误:无法将参数类型“String”分配给参数类型“Image”。
you need to pass the bytes not the base64你需要传递字节而不是 base64
it looks like you miss decodeImage()
看起来你错过了
decodeImage()
Future<List<int>> getImage() async {
List<int> bytes = [];
CapabilityProfile profile = await CapabilityProfile.load();
final generator = Generator(PaperSize.mm80, profile);
final ByteData data = await rootBundle.load('assets/logo.png');
final Uint8List buffer = data.buffer.asUint8List();
final Image image = decodeImage(buffer);
bytes += generator.image(image);
return bytes;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.