Committed by
David PHAM-VAN
Added pdfPreviewPageDecoration, scrollViewDecoration properties to PDFPreview Widget.
Showing
3 changed files
with
27 additions
and
5 deletions
@@ -26,6 +26,8 @@ class PdfPreview extends StatefulWidget { | @@ -26,6 +26,8 @@ class PdfPreview extends StatefulWidget { | ||
26 | this.onError, | 26 | this.onError, |
27 | this.onPrinted, | 27 | this.onPrinted, |
28 | this.onShared, | 28 | this.onShared, |
29 | + this.scrollViewDecoration, | ||
30 | + this.pdfPreviewPageDecoration, | ||
29 | }) : super(key: key); | 31 | }) : super(key: key); |
30 | 32 | ||
31 | /// Called when a pdf document is needed | 33 | /// Called when a pdf document is needed |
@@ -61,6 +63,12 @@ class PdfPreview extends StatefulWidget { | @@ -61,6 +63,12 @@ class PdfPreview extends StatefulWidget { | ||
61 | /// Called if the user shares the pdf document | 63 | /// Called if the user shares the pdf document |
62 | final void Function(BuildContext context) onShared; | 64 | final void Function(BuildContext context) onShared; |
63 | 65 | ||
66 | + /// Decoration of scrollView | ||
67 | + final Decoration scrollViewDecoration; | ||
68 | + | ||
69 | + /// Decoration of _PdfPreviewPage | ||
70 | + final Decoration pdfPreviewPageDecoration; | ||
71 | + | ||
64 | @override | 72 | @override |
65 | _PdfPreviewState createState() => _PdfPreviewState(); | 73 | _PdfPreviewState createState() => _PdfPreviewState(); |
66 | } | 74 | } |
@@ -110,9 +118,15 @@ class _PdfPreviewState extends State<PdfPreview> { | @@ -110,9 +118,15 @@ class _PdfPreviewState extends State<PdfPreview> { | ||
110 | await for (final PdfRaster page in Printing.raster(_doc, dpi: dpi)) { | 118 | await for (final PdfRaster page in Printing.raster(_doc, dpi: dpi)) { |
111 | setState(() { | 119 | setState(() { |
112 | if (pages.length <= pageNum) { | 120 | if (pages.length <= pageNum) { |
113 | - pages.add(_PdfPreviewPage(page: page)); | 121 | + pages.add(_PdfPreviewPage( |
122 | + page: page, | ||
123 | + pdfPreviewPageDecoration: widget.pdfPreviewPageDecoration, | ||
124 | + )); | ||
114 | } else { | 125 | } else { |
115 | - pages[pageNum] = _PdfPreviewPage(page: page); | 126 | + pages[pageNum] = _PdfPreviewPage( |
127 | + page: page, | ||
128 | + pdfPreviewPageDecoration: widget.pdfPreviewPageDecoration, | ||
129 | + ); | ||
116 | } | 130 | } |
117 | }); | 131 | }); |
118 | 132 | ||
@@ -220,7 +234,8 @@ class _PdfPreviewState extends State<PdfPreview> { | @@ -220,7 +234,8 @@ class _PdfPreviewState extends State<PdfPreview> { | ||
220 | final theme = Theme.of(context); | 234 | final theme = Theme.of(context); |
221 | 235 | ||
222 | final Widget scrollView = Container( | 236 | final Widget scrollView = Container( |
223 | - decoration: BoxDecoration( | 237 | + decoration: widget.scrollViewDecoration ?? |
238 | + BoxDecoration( | ||
224 | gradient: LinearGradient( | 239 | gradient: LinearGradient( |
225 | colors: <Color>[Colors.grey.shade400, Colors.grey.shade200], | 240 | colors: <Color>[Colors.grey.shade400, Colors.grey.shade200], |
226 | begin: Alignment.topCenter, | 241 | begin: Alignment.topCenter, |
@@ -380,9 +395,11 @@ class _PdfPreviewPage extends StatelessWidget { | @@ -380,9 +395,11 @@ class _PdfPreviewPage extends StatelessWidget { | ||
380 | const _PdfPreviewPage({ | 395 | const _PdfPreviewPage({ |
381 | Key key, | 396 | Key key, |
382 | this.page, | 397 | this.page, |
398 | + this.pdfPreviewPageDecoration, | ||
383 | }) : super(key: key); | 399 | }) : super(key: key); |
384 | 400 | ||
385 | final PdfRaster page; | 401 | final PdfRaster page; |
402 | + final Decoration pdfPreviewPageDecoration; | ||
386 | 403 | ||
387 | @override | 404 | @override |
388 | Widget build(BuildContext context) { | 405 | Widget build(BuildContext context) { |
@@ -395,7 +412,8 @@ class _PdfPreviewPage extends StatelessWidget { | @@ -395,7 +412,8 @@ class _PdfPreviewPage extends StatelessWidget { | ||
395 | right: 8, | 412 | right: 8, |
396 | bottom: 12, | 413 | bottom: 12, |
397 | ), | 414 | ), |
398 | - decoration: const BoxDecoration( | 415 | + decoration: pdfPreviewPageDecoration ?? |
416 | + const BoxDecoration( | ||
399 | color: Colors.white, | 417 | color: Colors.white, |
400 | boxShadow: <BoxShadow>[ | 418 | boxShadow: <BoxShadow>[ |
401 | BoxShadow( | 419 | BoxShadow( |
@@ -4,7 +4,7 @@ description: Plugin that allows Flutter apps to generate and print documents to | @@ -4,7 +4,7 @@ description: Plugin that allows Flutter apps to generate and print documents to | ||
4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing | 4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing |
5 | repository: https://github.com/DavBfr/dart_pdf | 5 | repository: https://github.com/DavBfr/dart_pdf |
6 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues | 6 | issue_tracker: https://github.com/DavBfr/dart_pdf/issues |
7 | -version: 3.4.0 | 7 | +version: 3.5.0 |
8 | 8 | ||
9 | environment: | 9 | environment: |
10 | sdk: ">=2.3.0 <3.0.0" | 10 | sdk: ">=2.3.0 <3.0.0" |
-
Please register or login to post a comment