postAndForget method

Future<void> postAndForget({
  1. CommandErrorCallback? onError,
})

Asynchronously sends this request to the server.

Fails if there are any event subscriptions to monitor the command execution. Use CommandRequest.post(..) for such scenarios.

Returns a future which completes when the request is sent. If there was a network problem, the future, completes with an error.

If the server rejects the command with an error and the onError callback is set, the callback will be triggered with the error. Otherwise, the error is silently ignored.

Implementation

Future<void> postAndForget({CommandErrorCallback? onError}) {
    if (_futureSubscriptions.isNotEmpty) {
        throw StateError('Use `post()` to add event subscriptions.');
    }
    return _client._postCommand(_command, onError);
}