ping static method

Future<Duration?> ping(
  1. Future request()
)

Ping the request & get the ping duration

Implementation

static Future<Duration?> ping(Future<dynamic> Function() request) async {
  final stopwatch = Stopwatch()..start();
  try {
    await request();
  } catch (e) {
    errorMessage = "ConnectivityChecker: Error to ping the request.\n$e";
    log(errorMessage!);
    return null;
  }
  stopwatch.stop();
  return stopwatch.elapsed;
}