【发布时间】:2019-12-07 10:00:33
【问题描述】:
PdfImage 需要 Uint8List 作为参数,但我有 ImageProvider。那么flutter中如何将image转为uint8list呢?
var imageProvider = AssetImage('assets/test.jpg');
final image = PdfImage(
pdf.document,
image:???, /// Uint8List required
width: img.width,
height: img.height,
);
【问题讨论】:
-
简单地使用
rootBundle.load(),因为它返回一个Future,你必须在load完成后使用then方法 -
你的答案在正常情况下是正确的。但就我而言,它有点不同。我必须以 pdf 格式渲染图像。所以,我需要在无状态小部件中没有异步函数的情况下工作
-
我在哪里说
async?我说:用then方法 -
我必须在返回无状态小部件的构建函数中使用它。那么,该怎么做呢?
-
Nope 使用包时无法使用:'package:flutter/widgets.dart' as fw;和“包:pdf/widgets.dart”
标签: image pdf image-processing flutter flutter-layout