Showing
3 changed files
with
12 additions
and
13 deletions
| @@ -28,12 +28,12 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; | @@ -28,12 +28,12 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; | ||
| 28 | import 'package:image/image.dart' as im; | 28 | import 'package:image/image.dart' as im; |
| 29 | import 'package:pdf/pdf.dart'; | 29 | import 'package:pdf/pdf.dart'; |
| 30 | 30 | ||
| 31 | -import 'callback.dart'; | ||
| 32 | -import 'interface.dart'; | ||
| 33 | -import 'pdfjs.dart'; | ||
| 34 | -import 'printer.dart'; | ||
| 35 | -import 'printing_info.dart'; | ||
| 36 | -import 'raster.dart'; | 31 | +import 'src/callback.dart'; |
| 32 | +import 'src/interface.dart'; | ||
| 33 | +import 'src/pdfjs.dart'; | ||
| 34 | +import 'src/printer.dart'; | ||
| 35 | +import 'src/printing_info.dart'; | ||
| 36 | +import 'src/raster.dart'; | ||
| 37 | 37 | ||
| 38 | /// Print plugin targetting Flutter on the Web | 38 | /// Print plugin targetting Flutter on the Web |
| 39 | class PrintingPlugin extends PrintingPlatform { | 39 | class PrintingPlugin extends PrintingPlatform { |
| @@ -120,10 +120,9 @@ class PrintingPlugin extends PrintingPlatform { | @@ -120,10 +120,9 @@ class PrintingPlugin extends PrintingPlatform { | ||
| 120 | ); | 120 | ); |
| 121 | final pdfUrl = html.Url.createObjectUrl(pdfFile); | 121 | final pdfUrl = html.Url.createObjectUrl(pdfFile); |
| 122 | final html.HtmlDocument doc = js.context['document']; | 122 | final html.HtmlDocument doc = js.context['document']; |
| 123 | - // ignore: avoid_as | ||
| 124 | - final link = doc.createElement('a') as html.AnchorElement; | ||
| 125 | - link.href = pdfUrl; | 123 | + final link = html.AnchorElement(href: pdfUrl); |
| 126 | link.target = '_blank'; | 124 | link.target = '_blank'; |
| 125 | + doc.body?.append(link); | ||
| 127 | link.click(); | 126 | link.click(); |
| 128 | link.remove(); | 127 | link.remove(); |
| 129 | return true; | 128 | return true; |
| @@ -141,10 +140,9 @@ class PrintingPlugin extends PrintingPlatform { | @@ -141,10 +140,9 @@ class PrintingPlugin extends PrintingPlatform { | ||
| 141 | ); | 140 | ); |
| 142 | final pdfUrl = html.Url.createObjectUrl(pdfFile); | 141 | final pdfUrl = html.Url.createObjectUrl(pdfFile); |
| 143 | final html.HtmlDocument doc = js.context['document']; | 142 | final html.HtmlDocument doc = js.context['document']; |
| 144 | - // ignore: avoid_as | ||
| 145 | - final link = doc.createElement('a') as html.AnchorElement; | ||
| 146 | - link.href = pdfUrl; | 143 | + final link = html.AnchorElement(href: pdfUrl); |
| 147 | link.download = filename; | 144 | link.download = filename; |
| 145 | + doc.body?.append(link); | ||
| 148 | link.click(); | 146 | link.click(); |
| 149 | link.remove(); | 147 | link.remove(); |
| 150 | return true; | 148 | return true; |
| @@ -47,7 +47,7 @@ flutter: | @@ -47,7 +47,7 @@ flutter: | ||
| 47 | macos: | 47 | macos: |
| 48 | pluginClass: PrintingPlugin | 48 | pluginClass: PrintingPlugin |
| 49 | web: | 49 | web: |
| 50 | - fileName: src/printing_web.dart | 50 | + fileName: printing_web.dart |
| 51 | pluginClass: PrintingPlugin | 51 | pluginClass: PrintingPlugin |
| 52 | windows: | 52 | windows: |
| 53 | pluginClass: PrintingPlugin | 53 | pluginClass: PrintingPlugin |
-
Please register or login to post a comment