Marcos Rodriguez
Committed by David PHAM-VAN

Added pdfPreviewPageDecoration, scrollViewDecoration properties to PDFPreview Widget.

1 # Changelog 1 # Changelog
2 2
  3 +## 3.5.0
  4 +
  5 +- Add decoration options to the PdfPreview Widget [Marcos Rodriguez]
  6 +
3 ## 3.4.0 7 ## 3.4.0
4 8
5 - Add PdfPreview Widget 9 - Add PdfPreview Widget
@@ -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,13 +234,14 @@ class _PdfPreviewState extends State<PdfPreview> { @@ -220,13 +234,14 @@ 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(  
224 - gradient: LinearGradient(  
225 - colors: <Color>[Colors.grey.shade400, Colors.grey.shade200],  
226 - begin: Alignment.topCenter,  
227 - end: Alignment.bottomCenter,  
228 - ),  
229 - ), 237 + decoration: widget.scrollViewDecoration ??
  238 + BoxDecoration(
  239 + gradient: LinearGradient(
  240 + colors: <Color>[Colors.grey.shade400, Colors.grey.shade200],
  241 + begin: Alignment.topCenter,
  242 + end: Alignment.bottomCenter,
  243 + ),
  244 + ),
230 width: double.infinity, 245 width: double.infinity,
231 alignment: Alignment.center, 246 alignment: Alignment.center,
232 child: Container( 247 child: Container(
@@ -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,16 +412,17 @@ class _PdfPreviewPage extends StatelessWidget { @@ -395,16 +412,17 @@ class _PdfPreviewPage extends StatelessWidget {
395 right: 8, 412 right: 8,
396 bottom: 12, 413 bottom: 12,
397 ), 414 ),
398 - decoration: const BoxDecoration(  
399 - color: Colors.white,  
400 - boxShadow: <BoxShadow>[  
401 - BoxShadow(  
402 - offset: Offset(0, 3),  
403 - blurRadius: 5,  
404 - color: Color(0xFF000000), 415 + decoration: pdfPreviewPageDecoration ??
  416 + const BoxDecoration(
  417 + color: Colors.white,
  418 + boxShadow: <BoxShadow>[
  419 + BoxShadow(
  420 + offset: Offset(0, 3),
  421 + blurRadius: 5,
  422 + color: Color(0xFF000000),
  423 + ),
  424 + ],
405 ), 425 ),
406 - ],  
407 - ),  
408 child: AspectRatio( 426 child: AspectRatio(
409 aspectRatio: page.width / page.height, 427 aspectRatio: page.width / page.height,
410 child: Image( 428 child: Image(
@@ -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"