Showing
11 changed files
with
116 additions
and
100 deletions
@@ -28,7 +28,7 @@ class App extends StatelessWidget { | @@ -28,7 +28,7 @@ class App extends StatelessWidget { | ||
28 | @override | 28 | @override |
29 | Widget build(BuildContext context) { | 29 | Widget build(BuildContext context) { |
30 | final scrollbarTheme = ScrollbarThemeData( | 30 | final scrollbarTheme = ScrollbarThemeData( |
31 | - thumbVisibility: MaterialStateProperty.all(true), | 31 | + thumbVisibility: WidgetStateProperty.all(true), |
32 | ); | 32 | ); |
33 | 33 | ||
34 | return MaterialApp( | 34 | return MaterialApp( |
@@ -193,8 +193,8 @@ To save the pdf file (Web): | @@ -193,8 +193,8 @@ To save the pdf file (Web): | ||
193 | ```dart | 193 | ```dart |
194 | var savedFile = await pdf.save(); | 194 | var savedFile = await pdf.save(); |
195 | List<int> fileInts = List.from(savedFile); | 195 | List<int> fileInts = List.from(savedFile); |
196 | -html.AnchorElement( | ||
197 | - href: "data:application/octet-stream;charset=utf-16le;base64,${base64.encode(fileInts)}") | 196 | +web.HTMLAnchorElement() |
197 | + ..href = "data:application/octet-stream;charset=utf-16le;base64,${base64.encode(fileInts)}" | ||
198 | ..setAttribute("download", "${DateTime.now().millisecondsSinceEpoch}.pdf") | 198 | ..setAttribute("download", "${DateTime.now().millisecondsSinceEpoch}.pdf") |
199 | ..click(); | 199 | ..click(); |
200 | ``` | 200 | ``` |
@@ -12,7 +12,7 @@ Future<void> main() async { | @@ -12,7 +12,7 @@ Future<void> main() async { | ||
12 | } | 12 | } |
13 | 13 | ||
14 | class MyApp extends StatelessWidget { | 14 | class MyApp extends StatelessWidget { |
15 | - const MyApp(this.title, {Key? key}) : super(key: key); | 15 | + const MyApp(this.title, {super.key}); |
16 | 16 | ||
17 | final String title; | 17 | final String title; |
18 | 18 |
@@ -15,15 +15,16 @@ | @@ -15,15 +15,16 @@ | ||
15 | */ | 15 | */ |
16 | 16 | ||
17 | import 'dart:async'; | 17 | import 'dart:async'; |
18 | -import 'dart:html' as html; | ||
19 | -import 'dart:js' as js; | ||
20 | -import 'dart:js_util'; | 18 | +import 'dart:js_interop' as js; |
19 | +import 'dart:js_interop_unsafe' as js; | ||
21 | import 'dart:typed_data'; | 20 | import 'dart:typed_data'; |
22 | import 'dart:ui'; | 21 | import 'dart:ui'; |
23 | 22 | ||
24 | import 'package:flutter/foundation.dart'; | 23 | import 'package:flutter/foundation.dart'; |
24 | +import 'package:flutter/services.dart'; | ||
25 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; | 25 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; |
26 | import 'package:pdf/pdf.dart'; | 26 | import 'package:pdf/pdf.dart'; |
27 | +import 'package:web/web.dart' as web; | ||
27 | 28 | ||
28 | import 'src/callback.dart'; | 29 | import 'src/callback.dart'; |
29 | import 'src/interface.dart'; | 30 | import 'src/interface.dart'; |
@@ -53,9 +54,12 @@ class PrintingPlugin extends PrintingPlatform { | @@ -53,9 +54,12 @@ class PrintingPlugin extends PrintingPlatform { | ||
53 | 54 | ||
54 | final _loading = Mutex(); | 55 | final _loading = Mutex(); |
55 | 56 | ||
56 | - bool get _hasPdfJsLib => js.context.callMethod('eval', <String>[ | ||
57 | - 'typeof pdfjsLib !== "undefined" && pdfjsLib.GlobalWorkerOptions.workerSrc != "";' | ||
58 | - ]); | 57 | + bool get _hasPdfJsLib => web.window |
58 | + .callMethod<js.JSBoolean>( | ||
59 | + 'eval'.toJS, | ||
60 | + 'typeof pdfjsLib !== "undefined" && pdfjsLib.GlobalWorkerOptions.workerSrc != "";' | ||
61 | + .toJS) | ||
62 | + .toDart; | ||
59 | 63 | ||
60 | /// The base URL for loading pdf.js library | 64 | /// The base URL for loading pdf.js library |
61 | late String _pdfJsUrlBase; | 65 | late String _pdfJsUrlBase; |
@@ -64,61 +68,65 @@ class PrintingPlugin extends PrintingPlatform { | @@ -64,61 +68,65 @@ class PrintingPlugin extends PrintingPlatform { | ||
64 | await _loading.acquire(); | 68 | await _loading.acquire(); |
65 | 69 | ||
66 | if (!_hasPdfJsLib) { | 70 | if (!_hasPdfJsLib) { |
67 | - dynamic amd; | ||
68 | - dynamic define; | ||
69 | - dynamic module; | ||
70 | - dynamic exports; | ||
71 | - if (js.context['define'] != null) { | 71 | + js.JSObject? amd; |
72 | + js.JSObject? define; | ||
73 | + js.JSObject? module; | ||
74 | + js.JSObject? exports; | ||
75 | + if (web.window.hasProperty('define'.toJS).toDart) { | ||
72 | // In dev, requireJs is loaded in. Disable it here. | 76 | // In dev, requireJs is loaded in. Disable it here. |
73 | - define = js.JsObject.fromBrowserObject(js.context['define']); | ||
74 | - amd = define['amd']; | ||
75 | - define['amd'] = false; | 77 | + define = web.window.getProperty('define'.toJS); |
78 | + amd = define!.getProperty('amd'.toJS); | ||
79 | + define.setProperty('amd'.toJS, false.toJS); | ||
76 | } | 80 | } |
77 | 81 | ||
78 | // Save Webpack values and make typeof module != object | 82 | // Save Webpack values and make typeof module != object |
79 | - if (js.context['exports'] != null) { | ||
80 | - exports = js.JsObject.fromBrowserObject(js.context['exports']); | 83 | + if (web.window.hasProperty('exports'.toJS).toDart) { |
84 | + exports = web.window.getProperty('exports'.toJS); | ||
81 | } | 85 | } |
82 | - js.context['exports'] = 0; | 86 | + web.window.setProperty('exports'.toJS, 0.toJS); |
83 | 87 | ||
84 | - if (js.context['module'] != null) { | ||
85 | - module = js.JsObject.fromBrowserObject(js.context['module']); | 88 | + if (web.window.hasProperty('module'.toJS).toDart) { |
89 | + module = web.window.getProperty('module'.toJS); | ||
86 | } | 90 | } |
87 | - js.context['module'] = 0; | 91 | + web.window.setProperty('module'.toJS, 0.toJS); |
88 | 92 | ||
89 | // Check if the source of PDF.js library is overridden via | 93 | // Check if the source of PDF.js library is overridden via |
90 | // [dartPdfJsBaseUrl] JavaScript variable. | 94 | // [dartPdfJsBaseUrl] JavaScript variable. |
91 | - if (js.context.hasProperty(_dartPdfJsBaseUrl)) { | ||
92 | - _pdfJsUrlBase = js.context[_dartPdfJsBaseUrl] as String; | 95 | + if (web.window.hasProperty(_dartPdfJsBaseUrl.toJS).toDart) { |
96 | + _pdfJsUrlBase = web.window[_dartPdfJsBaseUrl] as String; | ||
93 | } else { | 97 | } else { |
94 | - final pdfJsVersion = js.context.hasProperty(_dartPdfJsVersion) | ||
95 | - ? js.context[_dartPdfJsVersion] | ||
96 | - : _pdfJsVersion; | 98 | + final pdfJsVersion = |
99 | + web.window.hasProperty(_dartPdfJsVersion.toJS).toDart | ||
100 | + ? web.window[_dartPdfJsVersion] | ||
101 | + : _pdfJsVersion; | ||
97 | _pdfJsUrlBase = '$_pdfJsCdnPath@$pdfJsVersion/build/'; | 102 | _pdfJsUrlBase = '$_pdfJsCdnPath@$pdfJsVersion/build/'; |
98 | } | 103 | } |
99 | 104 | ||
100 | - final script = html.ScriptElement() | 105 | + final script = web.HTMLScriptElement() |
101 | ..type = 'text/javascript' | 106 | ..type = 'text/javascript' |
102 | ..async = true | 107 | ..async = true |
103 | ..src = '${_pdfJsUrlBase}pdf.min.js'; | 108 | ..src = '${_pdfJsUrlBase}pdf.min.js'; |
104 | - assert(html.document.head != null); | ||
105 | - html.document.head!.append(script); | 109 | + assert(web.document.head != null); |
110 | + web.document.head!.append(script); | ||
106 | await script.onLoad.first; | 111 | await script.onLoad.first; |
107 | 112 | ||
108 | if (amd != null) { | 113 | if (amd != null) { |
109 | // Re-enable requireJs | 114 | // Re-enable requireJs |
110 | - define['amd'] = amd; | 115 | + define!.setProperty('amd'.toJS, amd); |
111 | } | 116 | } |
112 | 117 | ||
113 | - js.context['pdfjsLib']['GlobalWorkerOptions']['workerSrc'] = | ||
114 | - '${_pdfJsUrlBase}pdf.worker.min.js'; | 118 | + web.window |
119 | + .getProperty<js.JSObject>('pdfjsLib'.toJS) | ||
120 | + .getProperty<js.JSObject>('GlobalWorkerOptions'.toJS) | ||
121 | + .setProperty( | ||
122 | + 'workerSrc'.toJS, '${_pdfJsUrlBase}pdf.worker.min.js'.toJS); | ||
115 | 123 | ||
116 | // Restore module and exports | 124 | // Restore module and exports |
117 | if (module != null) { | 125 | if (module != null) { |
118 | - js.context['module'] = module; | 126 | + web.window['module'] = module; |
119 | } | 127 | } |
120 | if (exports != null) { | 128 | if (exports != null) { |
121 | - js.context['exports'] = exports; | 129 | + web.window['exports'] = exports; |
122 | } | 130 | } |
123 | } | 131 | } |
124 | 132 | ||
@@ -173,9 +181,9 @@ class PrintingPlugin extends PrintingPlatform { | @@ -173,9 +181,9 @@ class PrintingPlugin extends PrintingPlatform { | ||
173 | return false; | 181 | return false; |
174 | } | 182 | } |
175 | 183 | ||
176 | - final String userAgent = js.context['navigator']['userAgent']; | ||
177 | - final isChrome = js.context['chrome'] != null; | ||
178 | - final isSafari = js.context['safari'] != null && | 184 | + final userAgent = web.window.navigator.userAgent; |
185 | + final isChrome = web.window['chrome'] != null; | ||
186 | + final isSafari = web.window['safari'] != null && | ||
179 | !userAgent.contains(RegExp(r'Version/14\.1\.')); | 187 | !userAgent.contains(RegExp(r'Version/14\.1\.')); |
180 | final isMobile = userAgent.contains('Mobile'); | 188 | final isMobile = userAgent.contains('Mobile'); |
181 | final isFirefox = userAgent.contains('Firefox'); | 189 | final isFirefox = userAgent.contains('Firefox'); |
@@ -183,18 +191,18 @@ class PrintingPlugin extends PrintingPlatform { | @@ -183,18 +191,18 @@ class PrintingPlugin extends PrintingPlatform { | ||
183 | // Chrome, Safari, and Firefox on a desktop computer | 191 | // Chrome, Safari, and Firefox on a desktop computer |
184 | if ((isChrome || isSafari || isFirefox) && !isMobile) { | 192 | if ((isChrome || isSafari || isFirefox) && !isMobile) { |
185 | final completer = Completer<bool>(); | 193 | final completer = Completer<bool>(); |
186 | - final pdfFile = html.Blob( | ||
187 | - <Uint8List>[result], | ||
188 | - 'application/pdf', | 194 | + final pdfFile = web.Blob( |
195 | + [result.toJS].toJS, | ||
196 | + web.BlobPropertyBag(type: 'application/pdf'), | ||
189 | ); | 197 | ); |
190 | - final pdfUrl = html.Url.createObjectUrl(pdfFile); | ||
191 | - final html.HtmlDocument doc = js.context['document']; | 198 | + final pdfUrl = web.URL.createObjectURL(pdfFile); |
199 | + final doc = web.window.document; | ||
192 | 200 | ||
193 | final script = | 201 | final script = |
194 | doc.getElementById(_scriptId) ?? doc.createElement('script'); | 202 | doc.getElementById(_scriptId) ?? doc.createElement('script'); |
195 | script.setAttribute('id', _scriptId); | 203 | script.setAttribute('id', _scriptId); |
196 | script.setAttribute('type', 'text/javascript'); | 204 | script.setAttribute('type', 'text/javascript'); |
197 | - script.innerText = | 205 | + script.innerHTML = |
198 | '''function ${_frameId}_print(){var f=document.getElementById('$_frameId');f.focus();f.contentWindow.print();}'''; | 206 | '''function ${_frameId}_print(){var f=document.getElementById('$_frameId');f.focus();f.contentWindow.print();}'''; |
199 | doc.body!.append(script); | 207 | doc.body!.append(script); |
200 | 208 | ||
@@ -218,13 +226,13 @@ class PrintingPlugin extends PrintingPlatform { | @@ -218,13 +226,13 @@ class PrintingPlugin extends PrintingPlatform { | ||
218 | frame.setAttribute('src', pdfUrl); | 226 | frame.setAttribute('src', pdfUrl); |
219 | final stopWatch = Stopwatch(); | 227 | final stopWatch = Stopwatch(); |
220 | 228 | ||
221 | - html.EventListener? load; | ||
222 | - load = (html.Event event) { | 229 | + web.EventListener? load; |
230 | + load = (web.Event event) { | ||
223 | frame.removeEventListener('load', load); | 231 | frame.removeEventListener('load', load); |
224 | Timer(Duration(milliseconds: isSafari ? 500 : 0), () { | 232 | Timer(Duration(milliseconds: isSafari ? 500 : 0), () { |
225 | try { | 233 | try { |
226 | stopWatch.start(); | 234 | stopWatch.start(); |
227 | - js.context.callMethod('${_frameId}_print'); | 235 | + web.window.callMethod('${_frameId}_print'.toJS); |
228 | stopWatch.stop(); | 236 | stopWatch.stop(); |
229 | completer.complete(true); | 237 | completer.complete(true); |
230 | } catch (e) { | 238 | } catch (e) { |
@@ -236,7 +244,7 @@ class PrintingPlugin extends PrintingPlatform { | @@ -236,7 +244,7 @@ class PrintingPlugin extends PrintingPlatform { | ||
236 | completer.complete(_getPdf(result)); | 244 | completer.complete(_getPdf(result)); |
237 | } | 245 | } |
238 | }); | 246 | }); |
239 | - }; | 247 | + }.toJS; |
240 | 248 | ||
241 | frame.addEventListener('load', load); | 249 | frame.addEventListener('load', load); |
242 | 250 | ||
@@ -267,13 +275,13 @@ class PrintingPlugin extends PrintingPlatform { | @@ -267,13 +275,13 @@ class PrintingPlugin extends PrintingPlatform { | ||
267 | } | 275 | } |
268 | 276 | ||
269 | Future<bool> _getPdf(Uint8List bytes, {String? filename}) async { | 277 | Future<bool> _getPdf(Uint8List bytes, {String? filename}) async { |
270 | - final pdfFile = html.Blob( | ||
271 | - <Uint8List>[bytes], | ||
272 | - 'application/pdf', | 278 | + final pdfFile = web.Blob( |
279 | + [bytes.toJS].toJS, | ||
280 | + web.BlobPropertyBag(type: 'application/pdf'), | ||
273 | ); | 281 | ); |
274 | - final pdfUrl = html.Url.createObjectUrl(pdfFile); | ||
275 | - final html.HtmlDocument doc = js.context['document']; | ||
276 | - final link = html.AnchorElement(href: pdfUrl); | 282 | + final pdfUrl = web.URL.createObjectURL(pdfFile); |
283 | + final doc = web.window.document; | ||
284 | + final link = web.HTMLAnchorElement()..href = pdfUrl; | ||
277 | if (filename != null) { | 285 | if (filename != null) { |
278 | link.download = filename; | 286 | link.download = filename; |
279 | } else { | 287 | } else { |
@@ -314,7 +322,7 @@ class PrintingPlugin extends PrintingPlatform { | @@ -314,7 +322,7 @@ class PrintingPlugin extends PrintingPlatform { | ||
314 | ) async* { | 322 | ) async* { |
315 | await _initPlugin(); | 323 | await _initPlugin(); |
316 | 324 | ||
317 | - final settings = Settings()..data = document; | 325 | + final settings = Settings()..data = document.toJS; |
318 | 326 | ||
319 | if (!_hasPdfJsLib) { | 327 | if (!_hasPdfJsLib) { |
320 | settings | 328 | settings |
@@ -322,21 +330,20 @@ class PrintingPlugin extends PrintingPlatform { | @@ -322,21 +330,20 @@ class PrintingPlugin extends PrintingPlatform { | ||
322 | ..cMapPacked = true; | 330 | ..cMapPacked = true; |
323 | } | 331 | } |
324 | 332 | ||
325 | - final jsDoc = PdfJs.getDocument(settings); | 333 | + final jsDoc = getDocument(settings); |
326 | try { | 334 | try { |
327 | - final doc = await promiseToFuture<PdfJsDoc>(jsDoc.promise); | 335 | + final doc = await jsDoc.promise.toDart; |
328 | final numPages = doc.numPages; | 336 | final numPages = doc.numPages; |
329 | 337 | ||
330 | - final html.CanvasElement canvas = | ||
331 | - js.context['document'].createElement('canvas'); | 338 | + final canvas = |
339 | + web.window.document.createElement('canvas') as web.HTMLCanvasElement; | ||
332 | 340 | ||
333 | - final context = canvas.getContext('2d') as html.CanvasRenderingContext2D?; | 341 | + final context = canvas.getContext('2d') as web.CanvasRenderingContext2D; |
334 | final computedPages = | 342 | final computedPages = |
335 | pages ?? Iterable<int>.generate(numPages, (index) => index); | 343 | pages ?? Iterable<int>.generate(numPages, (index) => index); |
336 | 344 | ||
337 | for (final pageIndex in computedPages) { | 345 | for (final pageIndex in computedPages) { |
338 | - final page = | ||
339 | - await promiseToFuture<PdfJsPage>(doc.getPage(pageIndex + 1)); | 346 | + final page = await doc.getPage(pageIndex + 1).toDart; |
340 | try { | 347 | try { |
341 | final viewport = | 348 | final viewport = |
342 | page.getViewport(Settings()..scale = dpi / PdfPageFormat.inch); | 349 | page.getViewport(Settings()..scale = dpi / PdfPageFormat.inch); |
@@ -345,28 +352,36 @@ class PrintingPlugin extends PrintingPlatform { | @@ -345,28 +352,36 @@ class PrintingPlugin extends PrintingPlatform { | ||
345 | canvas.width = viewport.width.toInt(); | 352 | canvas.width = viewport.width.toInt(); |
346 | 353 | ||
347 | final renderContext = Settings() | 354 | final renderContext = Settings() |
348 | - ..canvasContext = context! | 355 | + ..canvasContext = context |
349 | ..viewport = viewport; | 356 | ..viewport = viewport; |
350 | 357 | ||
351 | - await promiseToFuture<void>(page.render(renderContext).promise); | 358 | + await page.render(renderContext).promise.toDart; |
352 | 359 | ||
353 | // Convert the image to PNG | 360 | // Convert the image to PNG |
354 | final completer = Completer<void>(); | 361 | final completer = Completer<void>(); |
355 | - final blob = await canvas.toBlob(); | 362 | + final blobCompleter = Completer<web.Blob?>(); |
363 | + canvas.toBlob((web.Blob? blob) { | ||
364 | + blobCompleter.complete(blob); | ||
365 | + }.toJS); | ||
366 | + final blob = await blobCompleter.future; | ||
367 | + if (blob == null) { | ||
368 | + continue; | ||
369 | + } | ||
356 | final data = BytesBuilder(); | 370 | final data = BytesBuilder(); |
357 | - final r = html.FileReader(); | 371 | + final r = web.FileReader(); |
358 | r.readAsArrayBuffer(blob); | 372 | r.readAsArrayBuffer(blob); |
373 | + | ||
359 | r.onLoadEnd.listen( | 374 | r.onLoadEnd.listen( |
360 | - (html.ProgressEvent e) { | ||
361 | - data.add(r.result as List<int>); | 375 | + (web.ProgressEvent e) { |
376 | + data.add((r.result as js.JSArrayBuffer).toDart.asInt8List()); | ||
362 | completer.complete(); | 377 | completer.complete(); |
363 | }, | 378 | }, |
364 | ); | 379 | ); |
365 | await completer.future; | 380 | await completer.future; |
366 | 381 | ||
367 | yield _WebPdfRaster( | 382 | yield _WebPdfRaster( |
368 | - canvas.width!, | ||
369 | - canvas.height!, | 383 | + canvas.width, |
384 | + canvas.height, | ||
370 | data.toBytes(), | 385 | data.toBytes(), |
371 | ); | 386 | ); |
372 | } finally { | 387 | } finally { |
@@ -16,24 +16,22 @@ | @@ -16,24 +16,22 @@ | ||
16 | 16 | ||
17 | // ignore_for_file: public_member_api_docs | 17 | // ignore_for_file: public_member_api_docs |
18 | 18 | ||
19 | -@JS() | ||
20 | -library pdf.js; | 19 | +@JS('pdfjsLib') |
20 | +library; | ||
21 | 21 | ||
22 | -import 'dart:html'; | ||
23 | -import 'dart:typed_data'; | 22 | +import 'dart:js_interop'; |
24 | 23 | ||
25 | -import 'package:js/js.dart'; | 24 | +import 'package:web/web.dart'; |
26 | 25 | ||
27 | -// ignore: avoid_classes_with_only_static_members | ||
28 | -@JS('pdfjsLib') | ||
29 | -class PdfJs { | ||
30 | - external static PdfJsDocLoader getDocument(Settings data); | ||
31 | -} | 26 | +@JS() |
27 | +external PdfJsDocLoader getDocument(Settings data); | ||
32 | 28 | ||
33 | @anonymous | 29 | @anonymous |
34 | @JS() | 30 | @JS() |
35 | -class Settings { | ||
36 | - external set data(Uint8List value); | 31 | +extension type Settings._(JSObject _) implements JSObject { |
32 | + external factory Settings({JSUint8Array data}); | ||
33 | + | ||
34 | + external set data(JSUint8Array value); | ||
37 | external set scale(double value); | 35 | external set scale(double value); |
38 | external set canvasContext(CanvasRenderingContext2D value); | 36 | external set canvasContext(CanvasRenderingContext2D value); |
39 | external set viewport(PdfJsViewport value); | 37 | external set viewport(PdfJsViewport value); |
@@ -43,21 +41,21 @@ class Settings { | @@ -43,21 +41,21 @@ class Settings { | ||
43 | 41 | ||
44 | @anonymous | 42 | @anonymous |
45 | @JS() | 43 | @JS() |
46 | -class PdfJsDocLoader { | ||
47 | - external Future<PdfJsDoc> get promise; | ||
48 | - external Future<void> destroy(); | 44 | +extension type PdfJsDocLoader._(JSObject _) implements JSObject { |
45 | + external JSPromise<PdfJsDoc> get promise; | ||
46 | + external JSPromise<Null> destroy(); | ||
49 | } | 47 | } |
50 | 48 | ||
51 | @anonymous | 49 | @anonymous |
52 | @JS() | 50 | @JS() |
53 | -class PdfJsDoc { | ||
54 | - external Future<PdfJsPage> getPage(int num); | 51 | +extension type PdfJsDoc._(JSObject _) implements JSObject { |
52 | + external JSPromise<PdfJsPage> getPage(int num); | ||
55 | external int get numPages; | 53 | external int get numPages; |
56 | } | 54 | } |
57 | 55 | ||
58 | @anonymous | 56 | @anonymous |
59 | @JS() | 57 | @JS() |
60 | -class PdfJsPage { | 58 | +extension type PdfJsPage._(JSObject _) implements JSObject { |
61 | external PdfJsViewport getViewport(Settings data); | 59 | external PdfJsViewport getViewport(Settings data); |
62 | external PdfJsRender render(Settings data); | 60 | external PdfJsRender render(Settings data); |
63 | external bool cleanup(); | 61 | external bool cleanup(); |
@@ -65,13 +63,13 @@ class PdfJsPage { | @@ -65,13 +63,13 @@ class PdfJsPage { | ||
65 | 63 | ||
66 | @anonymous | 64 | @anonymous |
67 | @JS() | 65 | @JS() |
68 | -class PdfJsViewport { | 66 | +extension type PdfJsViewport._(JSObject _) implements JSObject { |
69 | external num get width; | 67 | external num get width; |
70 | external num get height; | 68 | external num get height; |
71 | } | 69 | } |
72 | 70 | ||
73 | @anonymous | 71 | @anonymous |
74 | @JS() | 72 | @JS() |
75 | -class PdfJsRender { | ||
76 | - external Future<void> get promise; | 73 | +extension type PdfJsRender._(JSObject _) implements JSObject { |
74 | + external JSPromise<Null> get promise; | ||
77 | } | 75 | } |
@@ -85,7 +85,7 @@ class PdfPreviewPage extends StatelessWidget { | @@ -85,7 +85,7 @@ class PdfPreviewPage extends StatelessWidget { | ||
85 | final scrollbarTrack = Theme.of(context) | 85 | final scrollbarTrack = Theme.of(context) |
86 | .scrollbarTheme | 86 | .scrollbarTheme |
87 | .thickness | 87 | .thickness |
88 | - ?.resolve({MaterialState.hovered}) ?? | 88 | + ?.resolve({WidgetState.hovered}) ?? |
89 | 12; | 89 | 12; |
90 | 90 | ||
91 | return Container( | 91 | return Container( |
@@ -15,10 +15,10 @@ topics: | @@ -15,10 +15,10 @@ topics: | ||
15 | 15 | ||
16 | - printing | 16 | - printing |
17 | - report | 17 | - report |
18 | -version: 5.12.0 | 18 | +version: 5.13.0 |
19 | 19 | ||
20 | environment: | 20 | environment: |
21 | - sdk: ">=3.0.0 <4.0.0" | 21 | + sdk: ">=3.3.0 <4.0.0" |
22 | flutter: ">=3.10.0" | 22 | flutter: ">=3.10.0" |
23 | 23 | ||
24 | dependencies: | 24 | dependencies: |
@@ -29,11 +29,11 @@ dependencies: | @@ -29,11 +29,11 @@ dependencies: | ||
29 | sdk: flutter | 29 | sdk: flutter |
30 | http: ">=0.13.0 <2.0.0" | 30 | http: ">=0.13.0 <2.0.0" |
31 | image: ^4.0.02 | 31 | image: ^4.0.02 |
32 | - js: ">=0.6.3 <1.0.0" | ||
33 | meta: ">=1.3.0 <2.0.0" | 32 | meta: ">=1.3.0 <2.0.0" |
34 | pdf: ^3.10.0 | 33 | pdf: ^3.10.0 |
35 | pdf_widget_wrapper: '>=1.0.0 <2.0.0' | 34 | pdf_widget_wrapper: '>=1.0.0 <2.0.0' |
36 | plugin_platform_interface: ^2.1.0 | 35 | plugin_platform_interface: ^2.1.0 |
36 | + web: ^0.5.1 | ||
37 | 37 | ||
38 | dev_dependencies: | 38 | dev_dependencies: |
39 | flutter_lints: ^3.0.0 | 39 | flutter_lints: ^3.0.0 |
@@ -58,7 +58,7 @@ void buildFile(String src, String dest, bool flutter) { | @@ -58,7 +58,7 @@ void buildFile(String src, String dest, bool flutter) { | ||
58 | 'import \'package:htmltopdfwidgets/htmltopdfwidgets.dart\' show HTMLToPdf;'); | 58 | 'import \'package:htmltopdfwidgets/htmltopdfwidgets.dart\' show HTMLToPdf;'); |
59 | } else { | 59 | } else { |
60 | st.writeln('import \'dart:convert\';'); | 60 | st.writeln('import \'dart:convert\';'); |
61 | - st.writeln('import \'dart:html\' as html;'); | 61 | + st.writeln('import \'package:web/web.dart\' as web;'); |
62 | } | 62 | } |
63 | st.writeln('import \'package:printing/printing.dart\';'); | 63 | st.writeln('import \'package:printing/printing.dart\';'); |
64 | st.writeln('import \'package:pdf/pdf.dart\';'); | 64 | st.writeln('import \'package:pdf/pdf.dart\';'); |
-
Please register or login to post a comment