-
Notifications
You must be signed in to change notification settings - Fork 276
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
How update UI in background using workmanager? #559
Comments
any solution for this? |
Hello! I didn't find a solution, I chose to install the "restart-app" package and restart the application when there are changes and the application is in the background. |
I have the same question. |
Yes, this can be done via IsolateNameServer. Register a port when starting the app: receivePort = ReceivePort();
IsolateNameServer.registerPortWithName(
receivePort!.sendPort,
'isolate_port',
); Lookup the port from the worker: final port = IsolateNameServer.lookupPortByName('isolate_port'); Send data from the worker: port.send(data); Listen on the main thread for new data from workers: receivePort!.listen((data) {
// Update your UI data, for example:
valueNotifier.value = data;
notifyListeners();
}); |
Hi, to put them in context
I am consuming an API, and I save the data to a local database (Hive), then I get this data using a Stream to the local database.
When I run Workmanager, when the app is minimized (in my case registerPeriodicTask), doing a get of the api and updating the data every 15', the data is updated in the DB but not in the UI (this happens when the app is in the background and you go back to the app -> foreground ).
I have already tried:
But nothing seems to work. Any idea how to correct it?
This is a basic example of my screen
This is a basic example of mi main
Thanks you.
The text was updated successfully, but these errors were encountered: