Julius Alibrown
Committed by David PHAM-VAN

Added mounted check for setState in printing>preview>raster

@@ -139,14 +139,17 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> { @@ -139,14 +139,17 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> {
139 context: ErrorDescription('while generating a PDF'), 139 context: ErrorDescription('while generating a PDF'),
140 informationCollector: collector, 140 informationCollector: collector,
141 )); 141 ));
  142 + if (mounted) {
142 setState(() { 143 setState(() {
143 error = exception; 144 error = exception;
144 _rastering = false; 145 _rastering = false;
145 }); 146 });
  147 + }
  148 +
146 return; 149 return;
147 } 150 }
148 151
149 - if (error != null) { 152 + if (error != null && mounted) {
150 setState(() { 153 setState(() {
151 error = null; 154 error = null;
152 }); 155 });
@@ -182,7 +185,10 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> { @@ -182,7 +185,10 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> {
182 pageMargin: widget.previewPageMargin, 185 pageMargin: widget.previewPageMargin,
183 ); 186 );
184 } 187 }
  188 +
  189 + if (mounted) {
185 setState(() {}); 190 setState(() {});
  191 + }
186 192
187 pageNum++; 193 pageNum++;
188 } 194 }
@@ -191,7 +197,9 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> { @@ -191,7 +197,9 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> {
191 pages[index].image.evict(); 197 pages[index].image.evict();
192 } 198 }
193 pages.removeRange(pageNum, pages.length); 199 pages.removeRange(pageNum, pages.length);
  200 + if (mounted) {
194 setState(() {}); 201 setState(() {});
  202 + }
195 } catch (exception, stack) { 203 } catch (exception, stack) {
196 InformationCollector? collector; 204 InformationCollector? collector;
197 205
@@ -210,10 +218,12 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> { @@ -210,10 +218,12 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> {
210 informationCollector: collector, 218 informationCollector: collector,
211 )); 219 ));
212 220
  221 + if (mounted) {
213 setState(() { 222 setState(() {
214 error = exception; 223 error = exception;
215 }); 224 });
216 } 225 }
  226 + }
217 227
218 _rastering = false; 228 _rastering = false;
219 } 229 }
@@ -6,7 +6,7 @@ description: > @@ -6,7 +6,7 @@ description: >
6 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing 6 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing
7 repository: https://github.com/DavBfr/dart_pdf 7 repository: https://github.com/DavBfr/dart_pdf
8 issue_tracker: https://github.com/DavBfr/dart_pdf/issues 8 issue_tracker: https://github.com/DavBfr/dart_pdf/issues
9 -version: 5.9.1 9 +version: 5.9.2
10 10
11 environment: 11 environment:
12 sdk: ">=2.12.0 <3.0.0" 12 sdk: ">=2.12.0 <3.0.0"