-
-
Notifications
You must be signed in to change notification settings - Fork 153
No type X is registered inside GetIt when used with workmanager package #103
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
Comments
This is pretty insane. Is looks like that the |
Ok, it looks like that the workmanager creates a separate isolate for the callback that's why it gets its own global variable instances. |
Thanks for quick response. Isolates is new to me. I might found a solution from workmanager's issues: And a sample code: https://gist.github.com/lmzach09/147236158999f2e5a5a75e469f9cba3c |
I don't think is possible to use get_it as to share objects btw both isolates. |
Thanks for quick response and sharing your experience. I did the same on define the same (duplicate) configurations that on app start (repository, moor db, shared prefs etc.) and workmanager's callbackDispatcher is the way to go for now, even the solution is not elegant, but it works! Please update here if you found a better solution, I will do the same. :) |
Sure I will, but unless workmanager's callbackDispatcher starts shearing same process with our UI isolate we should consider this more or like 2 different applications having access to same app storage. |
@2math So, did moor work by registering on |
@elias8 ,I think you may stuck in situation with "Locked DB", because from both isolates you manipulate same DB file. That is why if you make a change from first isolate the other can see them only if you call get for this data(no streams). I spend a day trying to link the moor DB from 2 isolates, but has no luck. Here is the documentation if you want to try, on success you should have 1 instance of the DB and streams will work on both isolates. |
Uh oh!
There was an error while loading. Please reload this page.
Hi there,
First of all, many thanks for creating such a great service locator package.
I only face this issue when used get_it with the following workmanager package:
https://pub.dev/packages/workmanager/
More specifically in it's callbackDispatcher method.
Let me show you code snippets to illustrate the issue:
The following is code of _callbackDispatcher method:
The following is error print out in the console:
As the code did registered the
Simple
instance usingregisterLazySingleton
, I have no idea why thegetIt<Simple>()
is unable to locate it, any clue?Appreciate your sharing if you have any idea. Thank in advanced.
By the way, I created the following github repo for you to reproduce the error in your PC:
https://github.com/limcheekin/flutter-getit-workmanager
The text was updated successfully, but these errors were encountered: