Reputation: 101
in flutter, if i need to execute a refresh every 60 seconds or do some code... in performance.. is better to use
Future.delayed(const Duration(milliseconds: (seconds * 1000)), () {
// Here you can write your code
});
or it's better
Timer _timer = new Timer(const Duration(milliseconds: (seconds * 1000)), () {
// Here you can write your code
});
or (suggested by Omer Gamliel )
Timer.periodic(Duration(seconds: 60), (timer) {
// Here you can write your code
});
what do you think?
Upvotes: 4
Views: 1390
Reputation: 101
According to the comment of pskink
Flutter documentation show that Future.delayed is a Timer masked for convenience by the function Future.delayed to execute only once.
So, they are equal.
Upvotes: 3