flutter_libphonenumber
flutter_libphonenumber copied to clipboard
Error starting app on chrome
libphonenumber.min.js:7 Uncaught TypeError: Cannot set properties of null (setting 'exports')
at libphonenumber.min.js:7:87
at libphonenumber.min.js:7:330
(anonymous) @ libphonenumber.min.js:7
(anonymous) @ libphonenumber.min.js:7
flutter_libphonenumber_web.dart:73 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'PhoneNumberUtil')
at getAllSupportedRegions (flutter_libphonenumber_web.dart:73:44)
at getAllSupportedRegions.next (<anonymous>)
at async_patch.dart:45:50
at _RootZone.runUnary (zone.dart:1661:54)
at _FutureListener.thenAwait.handleValue (future_impl.dart:147:18)
at handleValueCallback (future_impl.dart:784:44)
at _Future._propagateToListeners (future_impl.dart:813:13)
at async._AsyncCallbackEntry.new.callback (future_impl.dart:448:9)
at Object._microtaskLoop (schedule_microtask.dart:40:11)
at _startMicrotaskLoop (schedule_microtask.dart:49:5)
at async_patch.dart:177:15
Nice catch. I can reproduce it on the latest flutter 3.10, but it works fine in 3.7. It must be an issue in flutter that changed in the meantime.
It seems to be an error only in debug builds: https://github.com/flutter/flutter/issues/126713
I would say let's keep this open and track that issue above for a fix to land in flutter. There are some workarounds mentioned here: https://stackoverflow.com/questions/55113108/is-it-possible-to-lazily-use-js-libs-with-dart/55192098#55192098 and in the linked issue above.
Our web release have been blocked due to this issue, is there any update or workaround exists? Some of the workaround suggested doesn't solve the issue, in Release mode "flutter_libphonenumber" the code is pulled from CDN - https://cdn.jsdelivr.net/gh/ruimarinho/google-libphonenumber@b7fe84af9b553f0f2db765a6e20c27fa867a971d/dist/libphonenumber.min.js
Error details -
Uncaught TypeError: Cannot set properties of null (setting 'exports') at libphonenumber.min.js:7:87 at libphonenumber.min.js:7:330
@ramachandran-muthiah looking at the above issue, they also mention this is a related one: https://github.com/flutter/flutter/issues/126131
That says the fix has landed in flutter ~3 weeks ago. Does it still happen on the master channel now?
TypeError: Cannot set properties of null (setting 'exports')
https://cdn.jsdelivr.net/gh/ruimarinho/google-libphonenumber@b7fe84af9b553f0f2db765a6e20c27fa867a971d/dist/libphonenumber.min.js 7:87 <fn>
https://cdn.jsdelivr.net/gh/ruimarinho/google-libphonenumber@b7fe84af9b553f0f2db765a6e20c27fa867a971d/dist/libphonenumber.min.js 7:330 <fn>
TypeError: Cannot read properties of undefined (reading 'PhoneNumberUtil')
packages/flutter_libphonenumber_web/flutter_libphonenumber_web.dart 73:44 getAllSupportedRegions
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50
I got this error too in the latest version. Tried on Chrome.
TypeError: Cannot set properties of null (setting 'exports') Attempting to run flutter_libphonenumber 2.1.5 package example, and getting above error in Flutter 3.10.6. Runs on Android device, but not Chrome or Edge.
Tried the following to no avail:
`Future
context.callMethod('fixRequireJs');
await init();
...
`
@ramachandran-muthiah looking at the above issue, they also mention this is a related one: flutter/flutter#126131
That says the fix has landed in flutter ~3 weeks ago. Does it still happen on the master channel now?
Fix with Flutter 3.13.0, thanks !
Is it safe to close this now?