waitForLastPing method

  1. @override
Future<List> waitForLastPing({
  1. Duration? timeout,
})
inherited

Wait for all of the outstanding analytics pings to complete. The returned Future will always complete without errors. You can pass in an optional Duration to specify to only wait for a certain amount of time.

This method is particularly useful for command-line clients. Outstanding I/O requests will cause the VM to delay terminating the process. Generally, users won't want their CLI app to pause at the end of the process waiting for Google analytics requests to complete. This method allows CLI apps to delay for a short time waiting for GA requests to complete, and then do something like call dart:io's exit() explicitly themselves (or the close method below).

Implementation

@override
Future<List<dynamic>> waitForLastPing({Duration? timeout}) async {
  // If there are pending messages, send them now.
  if (_batchedEvents.isNotEmpty) {
    _trySendBatches(Completer<void>());
  }
  var f = Future.wait(_futures);
  if (timeout != null) f = f.timeout(timeout, onTimeout: () => []);
  return f;
}