Skip to content

Throws error when built for web -- Uncaught TypeError: Cannot read property 'cy' of null #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AlexMeuer opened this issue Oct 11, 2020 · 4 comments

Comments

@AlexMeuer
Copy link

Uncaught TypeError: Cannot read property 'cy' of null
    at mM.$1$0 (get_it_impl.dart:316)
    at mM.$0 (get_it_impl.dart:338)
    at MB.$0 (injection.config.dart:91)
    at cf.IP (get_it_impl.dart:135)
    at mM.$1$0 (get_it_impl.dart:326)
    at MF.$0 (injection.config.dart:74)
    at cf.IP (get_it_impl.dart:135)
    at mM.$1$0 (get_it_impl.dart:326)
    at main.dart:11
    at a7o.a (async_patch.dart:315)

Works fine when used with flutter run, but when built via flutter build web then loading the page results in the above error being printed to the console.

For context, my browser is Chrome and here is the output of flutter doctor -v

[✓] Flutter (Channel beta, 1.22.1, on Mac OS X 10.15.6 19G73, locale en-GB)
    • Flutter version 1.22.1 at /Users/alex/development/flutter
    • Framework revision f30b7f4db9 (3 days ago), 2020-10-08 10:06:30 -0700
    • Engine revision 75bef9f6c8
    • Dart version 2.10.1

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/alex/Library/Android/sdk
    • Platform android-30, build-tools 30.0.1
    • Java binary at: /Users/alex/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6821437/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Users/alex/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6821437/Android Studio.app/Contents
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.50.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.0

[✓] Connected device (2 available)
    • Web Server (web) • web-server • web-javascript • Flutter Tools
    • Chrome (web)     • chrome     • web-javascript • Google Chrome 85.0.4183.121

• No issues found!
@AlexMeuer
Copy link
Author

This is my bad. It has something to do with the types that I am registering via the injectable package.

@quetool
Copy link

quetool commented Aug 17, 2021

Hey man, I know it's an old issue but I am having the same one. Could you try recall how did you fix it?

@AlexMeuer
Copy link
Author

From what I remember, it might have been a few things:

  • Registering a type that is dependant on another type, but providing no concrete registration for the dependency.
  • Registering a type that depends on a platform plugin that has no web implementation (e.g. most storage plugins are like this)
  • Something else that I've completely forgetten.

I solved it in my case by removing registrations (or replacing with dummy impls) until the error stopped, and adding back in half at a time to find the culprit.

It would probably also help if you avoided minifying your code when building. If you're running it via flutter run this should be done for you, but you can package it all up like a release but for profiling with the command: flutter build web --profile --dart-define=Dart2jsOptimization=O0

@quetool
Copy link

quetool commented Aug 18, 2021

Thanks! I am indeed using Profile build mode but I didn't know that --dart-define value. Will try, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants