David PHAM-VAN

Allow reusing an ImageProvider and Font on multiple documents

... ... @@ -3,6 +3,7 @@
## 3.4.1
- Fix Nunito font parsing
- Allow reusing an ImageProvider and Font on multiple documents
## 3.4.0
... ... @@ -19,7 +20,7 @@
## 3.3.0
- Implement To be signed flieds
- Implement To be signed fields
- Improve Text rendering
- Add individual cell decoration
- Improve Bullet Widget
... ...
... ... @@ -128,14 +128,11 @@ class Font {
PdfFont? _pdfFont;
PdfFont? getFont(Context context) {
if (_pdfFont == null) {
if (_pdfFont == null || _pdfFont!.pdfDocument != context.document) {
final pdfDocument = context.document;
_pdfFont = buildFont(pdfDocument);
}
assert(_pdfFont!.pdfDocument == context.document,
'Do not reuse a Font object across multiple documents');
return _pdfFont;
}
... ...
... ... @@ -57,8 +57,10 @@ abstract class ImageProvider {
if (effectiveDpi == null || _cache[0] != null) {
_cache[0] ??= buildImage(context);
assert(_cache[0]!.pdfDocument == context.document,
'Do not reuse an ImageProvider object across multiple documents');
if (_cache[0]!.pdfDocument != context.document) {
_cache[0] = buildImage(context);
}
return _cache[0]!;
}
... ... @@ -69,8 +71,10 @@ abstract class ImageProvider {
_cache[width] ??= buildImage(context, width: width, height: height);
}
assert(_cache[width]!.pdfDocument == context.document,
'Do not reuse an ImageProvider object across multiple documents');
if (_cache[width]!.pdfDocument != context.document) {
_cache[width] = buildImage(context, width: width, height: height);
}
return _cache[width]!;
}
}
... ...