Skip to content

Dependencies lost after page reload in Flutter web app using get_it #373

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
ghost opened this issue Sep 2, 2024 · 2 comments
Closed

Dependencies lost after page reload in Flutter web app using get_it #373

ghost opened this issue Sep 2, 2024 · 2 comments

Comments

@ghost
Copy link

ghost commented Sep 2, 2024

Hi, I am using the get_it dependency injection package in a Flutter web app, and I encountered an issue when reloading the page.

In my Flutter web app, I initialize dependencies using get_it only after a user successfully authenticates. This setup works perfectly during normal usage. However, when the page is refreshed or reloaded, all the registered dependencies in get_it are lost, leading to "dependency not found" errors. This issue affects the app’s functionality post-authentication after a reload.

Steps to Reproduce:

  • Set up a Flutter web app with the get_it package.
    
  • Configure the app to initialize dependencies using get_it only after the user successfully authenticates.
    
  • Authenticate a user and verify that dependencies are properly registered and accessible.
    
  • Refresh or reload the web page in the browser.
    
  • Attempt to access a previously registered dependency.
    
  • Notice the "dependency not found" error, indicating the dependencies are lost.
    

Expected Behavior:

There should be a way to handle page reloads in web environments to ensure that dependencies are either persisted or re-initialized automatically. Guidance on best practices for using get_it in Flutter web apps, specifically when dependencies are tied to authentication states, would be very helpful.

@escamoteur
Copy link
Collaborator

hmmm, can you provide a small repro project? That definitely shouldn't happen. Without seeing your code I fear I have no idea to find out what is happening

@escamoteur
Copy link
Collaborator

sorry without more information I can't do anything here

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

1 participant