-1

I am getting value from http request within a function ,I need to execute a Function during a time (1 min) , So this function can repeat itself during this time (1 min) to analysis this value from http for every 1 min , can I do this ?

Mohamed Alaa
  • 131
  • 2
  • 11
  • Does this answer your question? [How to run code after some delay in Flutter?](https://stackoverflow.com/questions/49471063/how-to-run-code-after-some-delay-in-flutter) – Sanjay Sharma May 26 '20 at 17:51
  • 1
    @SanjaySharma The OP is asking for a method of periodically running code, not just once after a delay. – Christopher Moore May 26 '20 at 19:50
  • 1
    @ChristopherMoore I think it has the required help. Check [this](https://stackoverflow.com/a/59500175/4788260) – Sanjay Sharma May 26 '20 at 20:04
  • @SanjaySharma That should be added as an answer on **this** question with a link to that answer for credit as that question is not a duplicate. – Christopher Moore May 26 '20 at 20:10
  • @ChristopherMoore yes this should answer my question – Mohamed Alaa May 26 '20 at 21:23
  • An answer on this question should still be accepted or the question should be closed. – Christopher Moore May 26 '20 at 21:24
  • So change [this](https://api.dart.dev/stable/2.8.2/dart-async/Timer/Timer.periodic.html) to [this](https://stackoverflow.com/questions/49471063/how-to-run-code-after-some-delay-in-flutter/59500175#59500175) to accept your answer – Mohamed Alaa May 26 '20 at 21:33

1 Answers1

1

You can use Timer.periodic to periodically run a function with the given time.

You can read more about this here.

Example usage:

Timer.periodic(Duration(seconds: 5), (timer) {
  print(DateTime.now());
});
Christopher Moore
  • 15,626
  • 10
  • 42
  • 52