首页 > 解决方案 > 如何知道 Dio 库中的时间段服务器响应?

问题描述

如何知道Dio库中的时间段服务器响应?

我使用postman,它返回status, time period,size的响应, ...

在此处输入图像描述

如何在Dio lib 中获取值?(我需要它来写日志)

标签: flutterdio

解决方案


您可以使用秒表来测量请求花费了多少

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;

推荐阅读