DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.42k stars 633 forks source link

DartError: TypeError: "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.2.146/": type 'String' is not a subtype of type 'Never' #1761

Open MacDeveloper1 opened 1 month ago

MacDeveloper1 commented 1 month ago

In my project I used overriding feature for loading pdf.js from another cloud storage.

  <script>
    // PDF.js options
    var dartPdfJsBaseUrl = "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.2.146/";
  </script>

So the result URL should be https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.2.146/pdf.min.js.

Now I get this error:

DartError: TypeError: "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.2.146/": type 'String' is not a subtype of type 'Never'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3  throw_
errors.dart:296
dart-sdk/lib/_internal/js_shared/lib/rti.dart 1405:3                         _failedAsCheck
rti.dart:1405
dart-sdk/lib/_internal/js_shared/lib/rti.dart 1383:3                         _generalAsCheckImplementation
rti.dart:1383
dart-sdk/lib/_internal/js_shared/lib/rti.dart 1278:30                        _installSpecializedAsCheck
rti.dart:1278
dart-sdk/lib/_internal/js_shared/lib/js_interop_unsafe_patch.dart 20:7       JSObjectUnsafeUtilExtension.getProperty
js_interop_unsafe_patch.dart:20
packages/printing/printing_web.dart 98:36                                    _initPlugin
printing_web.dart:98
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50           <fn>
async_patch.dart:45
dart-sdk/lib/async/zone.dart 1661:54                                         runUnary
zone.dart:1661
dart-sdk/lib/async/future_impl.dart 163:18                                   handleValue
future_impl.dart:163
dart-sdk/lib/async/future_impl.dart 861:44                                   handleValueCallback
future_impl.dart:861
dart-sdk/lib/async/future_impl.dart 890:13                                   _propagateToListeners
future_impl.dart:890
dart-sdk/lib/async/future_impl.dart 666:5                                    [_completeWithValue]
future_impl.dart:666
dart-sdk/lib/async/future_impl.dart 736:7                                    callback
future_impl.dart:736
dart-sdk/lib/async/schedule_microtask.dart 40:11                             _microtaskLoop
schedule_microtask.dart:40
dart-sdk/lib/async/schedule_microtask.dart 49:5                              _startMicrotaskLoop
schedule_microtask.dart:49
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7           <fn>
flutter -v doctor [√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22631.4317], locale en-NL) • Flutter version 3.24.3 on channel stable at C:\data\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500 • Engine revision 36335019a8 • Dart version 3.5.3 • DevTools version 2.37.3 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\at\AppData\Local\Android\sdk • Platform android-34, build-tools 34.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [X] Visual Studio - develop Windows apps X Visual Studio not installed; this is necessary to develop Windows apps. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2023.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874) [√] VS Code (version 1.94.1) • VS Code at C:\Users\at\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.98.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.4317] • Chrome (web) • chrome • web-javascript • Google Chrome 129.0.6668.90 • Edge (web) • edge • web-javascript • Microsoft Edge 123.0.2420.65 [√] Network resources • All expected network resources are available. ! Doctor found issues in 1 category.
abdulrehmananwar commented 1 month ago

facing same error on web when i click on printer button . TypeError: null: type 'Null' is not a subtype of type 'JSObject'

my html code is <!DOCTYPE html>

pdfpreview
luccaslyra commented 1 month ago

Me too! Mine is a flutter web app testing on chrome. Before flutter 3.24.3 it was working fina, but now i got this erro: errors.dart:296 Uncaught (in promise) DartError: TypeError: null: type 'Null' is not a subtype of type 'JSObject' at Object.throw_ [as throw] (errors.dart:296:3) at Object._failedAsCheck (rti.dart:1405:3) at dart_rti.Rti.new._generalAsCheckImplementation (rti.dart:1383:3) at Object.getProperty (js_util_patch.dart:81:5) at printing_web.PrintingPlugin.new.layoutPdf (printing_web.dart:196:32) at layoutPdf.next () at async_patch.dart:45:50

Tushar2940 commented 2 weeks ago

facing same error on web when i click on printer button . printing: ^5.13.4

DartError: TypeError: "https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.2.146/": type 'String' is not a subtype of type 'Never' dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 296:3 throw dart-sdk/lib/_internal/js_shared/lib/rti.dart 1405:3 _failedAsCheck dart-sdk/lib/_internal/js_shared/lib/rti.dart 1383:3 _generalAsCheckImplementation dart-sdk/lib/_internal/js_shared/lib/rti.dart 1278:30 _installSpecializedAsCheck dart-sdk/lib/_internal/js_shared/lib/js_interop_unsafe_patch.dart 20:7 JSObjectUnsafeUtilExtension.getProperty packages/printing/printing_web.dart 98:36 _initPlugin dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 dart-sdk/lib/async/zone.dart 1661:54 runUnary dart-sdk/lib/async/future_impl.dart 163:18 handleValue dart-sdk/lib/async/future_impl.dart 861:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 890:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 666:5 [_completeWithValue] dart-sdk/lib/async/future_impl.dart 736:7 callback dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7

abdulrehmananwar commented 2 weeks ago

this error comes when you run on local host or http. butt when i run on https then error not comming you can try