Skip to content

How to open dialog only when request is taking too long time? #2197

Answered by SoroushBeigi
sollyow asked this question in Q&A
Discussion options

You must be logged in to vote

You can use a bool to know if the request is taking too long. it can be implemented like this:

//replace 200ms with desired timeout time
final timer = Timer(Duration(milliseconds: 200), () => emit(state.copyWith(isLoadingLong: true)));
await yourRequest();
timer.cancel();
emit(state.copyWith(isLoadingLong: false));

You can also use Dio's built-it CONNECT_TIMEOUT exception and set the timeout in BaseOptions

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sollyow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants