我有一个PDF的Base64内容,我需要在Flutter应用中显示它。
我正在尝试使用Dart的image、pdf和convert包,但是在image类中出现了错误,我不知道该如何显示这个图像。
List<int> pdfDataBytes = base64.decode(fileContent);
Image img = decodeImage(pdfDataBytes);
PdfImage image = PdfImage(
pdf,
image: img.data.buffer.asUint8List(),
width: img.width,
height: img.height);
图片类错误信息为:尝试使用“as前缀”来替代其中一个导入指令,或者只允许一个导入指令使用该名称。
final encodedStr = "在此处放置base64编码的字符串"; Uint8List bytes = base64.decode(encodedStr); String dir = (await getApplicationDocumentsDirectory()).path; File file = File( "$dir/" + DateTime.now().millisecondsSinceEpoch.toString() + ".pdf"); await file.writeAsBytes(bytes); return file.path; } - hawkbee