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?
According to the comment of pskink
Documentation
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With