injectable icon indicating copy to clipboard operation
injectable copied to clipboard

Error when using flutter web release

Open UlrichRaab opened this issue 4 years ago • 3 comments

Every time when i try to run my flutter app in web release or profile i get an error that DI failed.

zone.dart:1175 Uncaught TypeError: Cannot read property 'cx' of null
    at Nt.$1$0 (get_it_impl.dart:272)
    at main.dart:14
    at Qk.a (async_patch.dart:315)
    at Qk.$2 (async_patch.dart:340)
    at PN.$1 (async_patch.dart:291)
    at OP.KF (zone.dart:1450)
    at OP.pT (zone.dart:1449)
    at Np.$0 (future_impl.dart:109)
    at Object.lq (future_impl.dart:725)
    at U.jN (future_impl.dart:529)

My setup is quite simple. I have a new flutter app and added GetIt and Injectable. When i run

flutter run -d chrome --web-hostname localhost --web-port 4200 --release

the browser opens and shows a white page without any content. You can see the error using the dev tools of the browser.

Flotter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.21.0-9.2.pre, on Mac OS X 10.15.6 19G2021, locale
    de-CH)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
[✓] Chrome - develop for the web
[!] Android Studio (version 4.0)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.48.2)
[✓] Connected device (2 available)

! Doctor found issues in 1 category.

Example

https://github.com/UlrichRaab/injectable_test

UlrichRaab avatar Sep 11 '20 11:09 UlrichRaab

Hi, I have the same problem, when running release version of flutter web. In debug it works well. From my research initGetIt method isn't called on web-release.

maxpill avatar Feb 16 '21 10:02 maxpill

Injectable does not have a flutter dependency.

Milad-Akarie avatar Feb 27 '21 13:02 Milad-Akarie

So anyone knows what is the solution to this issue?

quetool avatar Aug 17 '21 15:08 quetool

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Feb 16 '23 08:02 github-actions[bot]