resolve method
Resolves this image provider using the given context, returning a PdfImage The image is automatically added to the document
Implementation
PdfImage resolve(Context context, PdfPoint size, {double? dpi}) {
final effectiveDpi = dpi ?? this.dpi;
if (effectiveDpi == null || _cache[0] != null) {
_cache[0] ??= buildImage(context);
if (_cache[0]!.pdfDocument != context.document) {
_cache[0] = buildImage(context);
}
return _cache[0]!;
}
final width = (size.x / PdfPageFormat.inch * effectiveDpi).toInt();
final height = (size.y / PdfPageFormat.inch * effectiveDpi).toInt();
if (!_cache.containsKey(width)) {
_cache[width] ??= buildImage(context, width: width, height: height);
}
if (_cache[width]!.pdfDocument != context.document) {
_cache[width] = buildImage(context, width: width, height: height);
}
return _cache[width]!;
}