ricardo-durao-3r
Committed by GitHub

Add custom loading widget to PdfPreview widget (#774)

* add custom loading widget to PdfPreview widget

* bump version to 5.5.0
1 # Changelog 1 # Changelog
2 2
  3 +## 5.5.0
  4 +
  5 +- Add custom loading widget to PdfPreview widget
  6 +
3 ## 5.4.3 7 ## 5.4.3
4 8
5 - Update Pdfium libraries 9 - Update Pdfium libraries
@@ -59,6 +59,7 @@ class PdfPreview extends StatefulWidget { @@ -59,6 +59,7 @@ class PdfPreview extends StatefulWidget {
59 this.previewPageMargin, 59 this.previewPageMargin,
60 this.padding, 60 this.padding,
61 this.shouldRepaint = false, 61 this.shouldRepaint = false,
  62 + this.loadingWidget,
62 }) : super(key: key); 63 }) : super(key: key);
63 64
64 static const _defaultPageFormats = <String, PdfPageFormat>{ 65 static const _defaultPageFormats = <String, PdfPageFormat>{
@@ -150,6 +151,10 @@ class PdfPreview extends StatefulWidget { @@ -150,6 +151,10 @@ class PdfPreview extends StatefulWidget {
150 /// Force repainting the PDF document 151 /// Force repainting the PDF document
151 final bool shouldRepaint; 152 final bool shouldRepaint;
152 153
  154 + /// Custom loading widget to use that is shown while PDF is being generated.
  155 + /// If null, a [CircularProgressIndicator] is used instead.
  156 + final Widget? loadingWidget;
  157 +
153 @override 158 @override
154 _PdfPreviewState createState() => _PdfPreviewState(); 159 _PdfPreviewState createState() => _PdfPreviewState();
155 } 160 }
@@ -287,7 +292,10 @@ class _PdfPreviewState extends State<PdfPreview> with PdfPreviewRaster { @@ -287,7 +292,10 @@ class _PdfPreviewState extends State<PdfPreview> with PdfPreviewRaster {
287 } 292 }
288 293
289 if (pages.isEmpty) { 294 if (pages.isEmpty) {
290 - return const Center(child: CircularProgressIndicator()); 295 + return widget.loadingWidget ??
  296 + const Center(
  297 + child: CircularProgressIndicator(),
  298 + );
291 } 299 }
292 300
293 return ListView.builder( 301 return ListView.builder(
@@ -7,7 +7,7 @@ description: > @@ -7,7 +7,7 @@ description: >
7 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing 7 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing
8 repository: https://github.com/DavBfr/dart_pdf 8 repository: https://github.com/DavBfr/dart_pdf
9 issue_tracker: https://github.com/DavBfr/dart_pdf/issues 9 issue_tracker: https://github.com/DavBfr/dart_pdf/issues
10 -version: 5.4.3 10 +version: 5.5.0
11 11
12 environment: 12 environment:
13 sdk: ">=2.12.0 <3.0.0" 13 sdk: ">=2.12.0 <3.0.0"