Showing
1 changed file
with
12 additions
and
3 deletions
| @@ -17,6 +17,7 @@ class PdfPreview extends StatefulWidget { | @@ -17,6 +17,7 @@ class PdfPreview extends StatefulWidget { | ||
| 17 | this.initialPageFormat, | 17 | this.initialPageFormat, |
| 18 | this.allowPrinting = true, | 18 | this.allowPrinting = true, |
| 19 | this.allowSharing = true, | 19 | this.allowSharing = true, |
| 20 | + this.maxPageWidth, | ||
| 20 | this.canChangePageFormat = true, | 21 | this.canChangePageFormat = true, |
| 21 | this.actions, | 22 | this.actions, |
| 22 | this.pageFormats, | 23 | this.pageFormats, |
| @@ -33,6 +34,8 @@ class PdfPreview extends StatefulWidget { | @@ -33,6 +34,8 @@ class PdfPreview extends StatefulWidget { | ||
| 33 | 34 | ||
| 34 | final bool allowSharing; | 35 | final bool allowSharing; |
| 35 | 36 | ||
| 37 | + final double maxPageWidth; | ||
| 38 | + | ||
| 36 | final bool canChangePageFormat; | 39 | final bool canChangePageFormat; |
| 37 | 40 | ||
| 38 | final List<PdfPreviewAction> actions; | 41 | final List<PdfPreviewAction> actions; |
| @@ -148,8 +151,8 @@ class _PdfPreviewState extends State<PdfPreview> { | @@ -148,8 +151,8 @@ class _PdfPreviewState extends State<PdfPreview> { | ||
| 148 | } | 151 | } |
| 149 | 152 | ||
| 150 | final MediaQueryData mq = MediaQuery.of(context); | 153 | final MediaQueryData mq = MediaQuery.of(context); |
| 151 | - dpi = (mq.size.width - 16) * | ||
| 152 | - min(mq.devicePixelRatio, 2) / | 154 | + dpi = (min(mq.size.width - 16, widget.maxPageWidth)) * |
| 155 | + mq.devicePixelRatio / | ||
| 153 | pageFormat.width * | 156 | pageFormat.width * |
| 154 | 72; | 157 | 72; |
| 155 | 158 | ||
| @@ -205,7 +208,6 @@ class _PdfPreviewState extends State<PdfPreview> { | @@ -205,7 +208,6 @@ class _PdfPreviewState extends State<PdfPreview> { | ||
| 205 | final ThemeData theme = Theme.of(context); | 208 | final ThemeData theme = Theme.of(context); |
| 206 | 209 | ||
| 207 | final Widget scrollView = Container( | 210 | final Widget scrollView = Container( |
| 208 | - width: double.infinity, | ||
| 209 | decoration: BoxDecoration( | 211 | decoration: BoxDecoration( |
| 210 | gradient: LinearGradient( | 212 | gradient: LinearGradient( |
| 211 | colors: <Color>[Colors.grey.shade400, Colors.grey.shade200], | 213 | colors: <Color>[Colors.grey.shade400, Colors.grey.shade200], |
| @@ -213,7 +215,14 @@ class _PdfPreviewState extends State<PdfPreview> { | @@ -213,7 +215,14 @@ class _PdfPreviewState extends State<PdfPreview> { | ||
| 213 | end: Alignment.bottomCenter, | 215 | end: Alignment.bottomCenter, |
| 214 | ), | 216 | ), |
| 215 | ), | 217 | ), |
| 218 | + width: double.infinity, | ||
| 219 | + alignment: Alignment.center, | ||
| 220 | + child: Container( | ||
| 221 | + constraints: widget.maxPageWidth != null | ||
| 222 | + ? BoxConstraints(maxWidth: widget.maxPageWidth) | ||
| 223 | + : null, | ||
| 216 | child: _createPreview(), | 224 | child: _createPreview(), |
| 225 | + ), | ||
| 217 | ); | 226 | ); |
| 218 | 227 | ||
| 219 | final List<Widget> actions = <Widget>[]; | 228 | final List<Widget> actions = <Widget>[]; |
-
Please register or login to post a comment