Committed by
David PHAM-VAN
Added mounted check for setState in printing>preview>raster
Showing
2 changed files
with
21 additions
and
11 deletions
@@ -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 | - setState(() { | ||
143 | - error = exception; | ||
144 | - _rastering = false; | ||
145 | - }); | 142 | + if (mounted) { |
143 | + setState(() { | ||
144 | + error = exception; | ||
145 | + _rastering = false; | ||
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 | } |
185 | - setState(() {}); | 188 | + |
189 | + if (mounted) { | ||
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); |
194 | - setState(() {}); | 200 | + if (mounted) { |
201 | + setState(() {}); | ||
202 | + } | ||
195 | } catch (exception, stack) { | 203 | } catch (exception, stack) { |
196 | InformationCollector? collector; | 204 | InformationCollector? collector; |
197 | 205 | ||
@@ -210,9 +218,11 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> { | @@ -210,9 +218,11 @@ mixin PdfPreviewRaster on State<PdfPreviewCustom> { | ||
210 | informationCollector: collector, | 218 | informationCollector: collector, |
211 | )); | 219 | )); |
212 | 220 | ||
213 | - setState(() { | ||
214 | - error = exception; | ||
215 | - }); | 221 | + if (mounted) { |
222 | + setState(() { | ||
223 | + error = exception; | ||
224 | + }); | ||
225 | + } | ||
216 | } | 226 | } |
217 | 227 | ||
218 | _rastering = false; | 228 | _rastering = false; |
@@ -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" |
-
Please register or login to post a comment