I am using flutter. I wrote a function, if it takes longer than 5 seconds, I want to redirect it to the page with a warning message. Is there an easy way to do this?
Asked
Active
Viewed 678 times
1 Answers
2
Your future function :
Future<void> func() async {}
Add timeout listener :
func().timeout(const Duration (seconds:5),onTimeout : () {
// move to the page with warning message
});

manhtuan21
- 2,388
- 2
- 10
- 24