Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know the time period server response in the Dio library?

Tags:

flutter

dio

How to know the time period server response in the Dio library?

I use postman, it returns status, time period, size of the response, ...

enter image description here

How to get values in Dio lib? (I need it to write log)

like image 437
Huu Bao Nguyen Avatar asked Sep 06 '25 00:09

Huu Bao Nguyen


1 Answers

You could use a stop watch to measure how much the request took

var stopWatch = Stopwatch();
    
stopWatch.start();
performReques();
stopWatch.stop();

// convert the duration to string
var elapsedString = stopWatch.elapsed.toString();

// or just get duration in seconds
var elapsedSeconds = stopWatch.elapsed.inSeconds;
like image 78
Claudio Redi Avatar answered Sep 09 '25 23:09

Claudio Redi