Skip to content

[BUG] Wrong work of get_it in release/profile mode flutter web #245

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
bohdan1krokhmaliuk opened this issue Jan 18, 2022 · 4 comments
Closed
Labels
bug Something isn't working web

Comments

@bohdan1krokhmaliuk
Copy link

bohdan1krokhmaliuk commented Jan 18, 2022

Having such issue in my main project. I see no idea how to fix it and it looks like get_it issue.
Code works fine if it runs in debug mode but as soon as we run it in profile or production - it simply crashes.

I found other people who have same issues with get_it so probably it is critical. Thanks for help!

Minimum reproducible code: https://github.com/bohdan1krokhmaliuk/get_it_issue.git
To reproduce:

  • open project
  • flutter build web --profile --dart-define=Dart2jsOptimization=O0
  • cd build/web
  • python3 -m http.server 8000
  • checkout localhost:8000

image

@escamoteur escamoteur added bug Something isn't working web labels Feb 2, 2022
@bohdan1krokhmaliuk
Copy link
Author

@escamoteur This problem is connected somehow to the way it is used. In case I pass GetIt.instance as an injected dependency (via constructor to my custom ServiceLocator class as example) - it emits this error. In case I use it as static GetIt.instance instead of an injected dependency - it works fine on web.
Mobile doesn't have such problem. Hope it can help

@HKop
Copy link

HKop commented Feb 2, 2022

Hi, I created a simple project that reproduces the same issue for me (HERE: https://github.com/HKop/getit-issue) It started happening once we extracted some of the files to a "lib_common" library and wanted to use them in the main app.

Project structure:

  1. getIt_issue main project.
  2. lib_common library in getIt_issue folder that has components used in the main project.

Note: Issue is only present on web in release or profile mode.

  1. To generate getIt files - "flutter packages pub run build_runner build --delete-conflicting-outputs" in the root getIt_issue folder;
  2. Then to run the app on web in profile mode - "flutter run --profile -d chrome --dart-define=Dart2jsOptimization=O0"

When opening the console, the same error is shown, yet works properly in debug mode.

@escamoteur
Copy link
Collaborator

escamoteur commented Feb 3, 2022 via email

@escamoteur
Copy link
Collaborator

duplicate of #238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working web
Projects
None yet
Development

No branches or pull requests

3 participants