fluttercommunity / get_it

Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur
https://pub.dev/packages/get_it
MIT License
1.36k stars 149 forks source link

Error: Object/factory with type CdbStore is not registered inside GetIt when navigating to second page in test #328

Closed thiagosmagalhaes closed 8 months ago

thiagosmagalhaes commented 1 year ago

I am encountering an error while running my test. The test involves registering a CdbStore in the GetIt service locator, loading the first page of a widget, and then navigating to a second page. Both pages access the CdbStore using .get(). However, when the second page is accessed during the test, I receive the following error: "Object/factory with type CdbStore is not registered inside GetIt."

Steps to reproduce:

Register CdbStore in the GetIt service locator. Load the first page of the widget. Navigate to the second page, which also accesses CdbStore using .get(). Expected behavior: The CdbStore should be successfully retrieved from the GetIt service locator on both the first and second pages, without any errors.

Actual behavior: When accessing the second page during the test, the error "Object/factory with type CdbStore is not registered inside GetIt" is thrown.

Additional information:

I have verified that the CdbStore is correctly registered in the GetIt service locator before running the test. The error only occurs when accessing the second page during the test. The first page is able to retrieve the CdbStore without any issues. The issue seems to be related to the test environment or navigation between pages, as the registration and retrieval of CdbStore work fine in the regular app flow. Environment:

get_it version: 7.2 I would appreciate any assistance in resolving this issue. Thank you!

thiagosmagalhaes commented 1 year ago

I tested it on version 7.6 but the problem remains

escamoteur commented 1 year ago

hmm difficult to pinpoint with that information. Could you create a small sample project that shows this behaviour?

sunjoong85 commented 1 year ago

I have similar issues. Getit with Chrome works fine. But, iPhone and iOS emulator shows exactly same errors that you posted.

escamoteur commented 1 year ago

Please, I need a small reproduction project so I can debug this Am 3. Juni 2023, 08:27 +0200 schrieb Sunjoong Kim @.***>:

I have similar issues. Getit with Chrome works fine. But, iPhone and iOS emulator shows exactly same errors that you posted. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

escamoteur commented 1 year ago

any news on this?

leferrad commented 2 weeks ago

I had the same error - working well with Chrome but having the error in Safari (iOS). Let me know what to provide to inspect better this error.

escamoteur commented 2 weeks ago

Can you please create a minimal repro project so I can reproduce and debug? Am 18. Nov. 2024, 00:35 +0100 schrieb Leandro Ferrado @.***>:

I had the same error - working well with Chrome but having the error in Safari (iOS). Let me know what to provide to inspect better this error. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

leferrad commented 2 weeks ago

Can you please create a minimal repro project so I can reproduce and debug? Am 18. Nov. 2024, 00:35 +0100 schrieb Leandro Ferrado @.>: I had the same error - working well with Chrome but having the error in Safari (iOS). Let me know what to provide to inspect better this error. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.>

I was creating a simple project to allow reproducing the error, but then it didn't happen - so after isolating everything on my actual app I figured the error happened in the GetIt call but because of another silent error. So dismiss my comment, this is not an issue with this package. Thanks for the response!