transmit method

Future<TaskStatusUpdate> transmit(
  1. DataTask task, {
  2. void onStatus(
    1. TaskStatus
    )?,
  3. void onElapsedTime(
    1. Duration
    )?,
  4. Duration? elapsedTimeInterval,
})

Transmit data in the DataTask and receive the response

Different from enqueue, this method returns a Future that completes when the DataTask has completed, or an error has occurred. While it uses the same mechanism as enqueue, and will execute the task also when the app moves to the background, it is meant for data tasks that are awaited while the app is in the foreground.

onStatus is an optional callback for status updates

An optional callback onElapsedTime will be called at regular intervals (defined by elapsedTimeInterval, which defaults to 5 seconds) with a single argument that is the elapsed time since the call to transmit. This can be used to trigger UI warnings (e.g. 'this is taking rather long') For performance reasons the elapsedTimeInterval should not be set to a value less than one second.

Implementation

Future<TaskStatusUpdate> transmit(DataTask task,
        {void Function(TaskStatus)? onStatus,
        void Function(Duration)? onElapsedTime,
        Duration? elapsedTimeInterval}) =>
    _downloader.enqueueAndAwait(task,
        onStatus: onStatus,
        onElapsedTime: onElapsedTime,
        elapsedTimeInterval: elapsedTimeInterval);