Reputation: 19
I have a function and I want to request this function again every second. How can I do that?
For example
getMessage(){}
I want to send a request to this function every second and see if there are new messages. How can I do that?
Upvotes: 1
Views: 584
Reputation: 8202
You can use Timer.periodic
for that:
Timer.periodic(
const Duration(seconds: 1),
(timer) => getMessage(),
);
Upvotes: 2