DavBfr / dart_pdf

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

package:printing doesn't work with package:web v1.1.0 #1747

Closed xvrh closed 1 month ago

xvrh commented 1 month ago

package:printing doesn't work with the latest version of package:web (1.1.0)

There is a compilation error when compiling for the Web

Target dart2js failed: ProcessException: Process exited abnormally with exit code 1:
../../../../../.pub-cache/hosted/pub.dev/printing-5.13.2/lib/printing_web.dart:132:19:
Error: The operator '[]=' isn't defined for the class 'Window'.
        web.window['module'] = module;
                  ^
../../../../../.pub-cache/hosted/pub.dev/printing-5.13.2/lib/printing_web.dart:135:19:
Error: The operator '[]=' isn't defined for the class 'Window'.
        web.window['exports'] = exports;
                  ^
Error: Compilation failed.

To Reproduce Compile a Flutter app for the web plaform with both package:printing and package:web: 1.1.0

Desktop (please complete the following information):

HiramaniPatel commented 1 month ago

I have also get same error on complilation in web

Target dart2js failed: ProcessException: Process exited abnormally with exit code 1: ../../.pub-cache/hosted/pub.dev/printing-5.13.2/lib/printing_web.dart:132:19: Error: The operator '[]=' isn't defined for the class 'Window'. web.window['module'] = module; ^ ../../.pub-cache/hosted/pub.dev/printing-5.13.2/lib/printing_web.dart:135:19: Error: The operator '[]=' isn't defined for the class 'Window'. web.window['exports'] = exports; ^

wechulimaven commented 1 month ago

Im also experiencing the same issue . Any help ../../../.pub-cache/hosted/pub.dev/printing-5.13.2/lib/printing_web.dart:132:19: Error: The operator '[]=' isn't defined for the class 'Window'. Try correcting the operator to an existing operator, or defining a '[]=' operator. web.window['module'] = module; ^

ifuterman commented 1 month ago

For me the same

dompetriella commented 1 month ago

Looks like the problem is with the 1.1.0 upgrade of the "web" package. image

https://pub.dev/packages/web/changelog

maxjevon247 commented 1 month ago

open printing_web.dart by clicking on the ../../../.pub-cache/hosted/pub.dev/printing-5.13.2/lib/printing_web.dart:132:19:

import 'dart:js' as js;

// Other imports and code...

replace the web.window with js.context // Corrected lines js.context['module'] = module; js.context['exports'] = exports;

this works for me

AlexFeldmeier commented 1 month ago

Changing the cached version will have issues if you do CI/CD or have multiple machines on the same project. Another temporary fix is to lock web to 1.0.0

dependencies:
  web: 1.0.0
ifuterman commented 1 month ago

Changing the cached version will have issues if you do CI/CD or have multiple machines on the same project. Another temporary fix is to lock web to 1.0.0

dependencies:
  web: 1.0.0

More correct way:

dependency_overrides:
   web: 1.0.0
Ammutadori83 commented 1 month ago

/C:/Users/.../AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.13.2/lib/printing_web.dart:132:19: Error: The operator '[]=' isn't defined for the class 'Window'. Try correcting the operator to an existing operator, or defining a '[]=' operator. web.window['module'] = module; ^ /C:/Users/.../AppData/Local/Pub/Cache/hosted/pub.dev/printing-5.13.2/lib/printing_web.dart:135:19: Error: The operator '[]=' isn't defined for the class 'Window'. Try correcting the operator to an existing operator, or defining a '[]=' operator. web.window['exports'] = exports; ^ Failed to compile application.

same for me

dependencies:
  web: 1.0.0

and

  replace the web.window with js.context
// Corrected lines
js.context['module'] = module;
js.context['exports'] = exports;

didn't work

DavBfr commented 1 month ago

The master branch is compatible, I'll publish a new version soon.

DavBfr commented 1 month ago

Fixed in printing 5.13.3