David PHAM-VAN

ImageProvider.resolve returns non-null object

@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 - Add individual cell decoration 7 - Add individual cell decoration
8 - Improve Bullet Widget 8 - Improve Bullet Widget
9 - Use covariant on SpanningWidget 9 - Use covariant on SpanningWidget
  10 +- ImageProvider.resolve returns non-null object
10 11
11 ## 3.2.0 12 ## 3.2.0
12 13
@@ -53,7 +53,7 @@ class DecorationImage extends DecorationGraphic { @@ -53,7 +53,7 @@ class DecorationImage extends DecorationGraphic {
53 53
54 @override 54 @override
55 void paint(Context context, PdfRect box) { 55 void paint(Context context, PdfRect box) {
56 - final _image = image.resolve(context, box.size, dpi: dpi)!; 56 + final _image = image.resolve(context, box.size, dpi: dpi);
57 57
58 final imageSize = 58 final imageSize =
59 PdfPoint(_image.width.toDouble(), _image.height.toDouble()); 59 PdfPoint(_image.width.toDouble(), _image.height.toDouble());
@@ -121,7 +121,7 @@ class Image extends Widget { @@ -121,7 +121,7 @@ class Image extends Widget {
121 121
122 _paintImage( 122 _paintImage(
123 canvas: context.canvas, 123 canvas: context.canvas,
124 - image: image.resolve(context, rect.size, dpi: dpi)!, 124 + image: image.resolve(context, rect.size, dpi: dpi),
125 rect: box!, 125 rect: box!,
126 alignment: alignment, 126 alignment: alignment,
127 fit: fit, 127 fit: fit,
@@ -51,7 +51,7 @@ abstract class ImageProvider { @@ -51,7 +51,7 @@ abstract class ImageProvider {
51 51
52 /// Resolves this image provider using the given context, returning a PdfImage 52 /// Resolves this image provider using the given context, returning a PdfImage
53 /// The image is automatically added to the document 53 /// The image is automatically added to the document
54 - PdfImage? resolve(Context context, PdfPoint size, {double? dpi}) { 54 + PdfImage resolve(Context context, PdfPoint size, {double? dpi}) {
55 final effectiveDpi = dpi ?? this.dpi; 55 final effectiveDpi = dpi ?? this.dpi;
56 56
57 if (effectiveDpi == null || _cache[0] != null) { 57 if (effectiveDpi == null || _cache[0] != null) {
@@ -59,7 +59,7 @@ abstract class ImageProvider { @@ -59,7 +59,7 @@ abstract class ImageProvider {
59 59
60 assert(_cache[0]!.pdfDocument == context.document, 60 assert(_cache[0]!.pdfDocument == context.document,
61 'Do not reuse an ImageProvider object across multiple documents'); 61 'Do not reuse an ImageProvider object across multiple documents');
62 - return _cache[0]; 62 + return _cache[0]!;
63 } 63 }
64 64
65 final width = (size.x / PdfPageFormat.inch * effectiveDpi).toInt(); 65 final width = (size.x / PdfPageFormat.inch * effectiveDpi).toInt();
@@ -71,7 +71,7 @@ abstract class ImageProvider { @@ -71,7 +71,7 @@ abstract class ImageProvider {
71 71
72 assert(_cache[width]!.pdfDocument == context.document, 72 assert(_cache[width]!.pdfDocument == context.document,
73 'Do not reuse an ImageProvider object across multiple documents'); 73 'Do not reuse an ImageProvider object across multiple documents');
74 - return _cache[width]; 74 + return _cache[width]!;
75 } 75 }
76 } 76 }
77 77