computib
Committed by David PHAM-VAN

PdfPreview unhandled exception when popped

When route which contains PdfPreview is popped, we got a:
Unhandled Exception: setState() called after dispose()

The solution is to add if (!mounted) return; in the file pdf_preview.dart in the function _raster() just after await for (final PdfRaster page in Printing.raster(_doc, dpi: dpi)) {
... ... @@ -3,6 +3,7 @@
## 3.6.0
- Added pdfFileName prop to PdfPreview Widget [Marcos Rodriguez]
- Fix PdfPreview unhandled exception when popped [computib]
## 3.5.0
... ...
... ... @@ -120,6 +120,9 @@ class _PdfPreviewState extends State<PdfPreview> {
var pageNum = 0;
await for (final PdfRaster page in Printing.raster(_doc, dpi: dpi)) {
if (!mounted) {
return;
}
setState(() {
if (pages.length <= pageNum) {
pages.add(_PdfPreviewPage(
... ...