I want to send log to server periodically after 30 sec. For performance i want to use different thread by using compute function. But Timer is not working in compute. Any suggestions to do task in different threads periodically in flutter?
Asked
Active
Viewed 270 times
1 Answers
1
You could just use an Isolate
directly. It's what compute
does under the hood.
However, I don't think sending information to a server would block your UI thread too much.
On top of that, if you're using app state to determine the log message I would just keep it in the main Isolate
.
I would probably wrap the (Material|Widget|Cupertino)App in a StatefulWidget and add a Timer.periodic
in the initState
.
You also have to note communicating with an Isolate
means your message has to be copied to its memory. While sending an HTTP Request to a server is usually async
and non-ui-blocking.

Jelly Legend
- 201
- 1
- 5