votePoll method Null safety

Future<Poll> votePoll(
  1. {required int pollId,
  2. required List<int> pollOptionIds,
  3. OnPollCallback? onCompleted}
)

Cast/ Cancel Poll Vote

Implementation

Future<Poll> votePoll({
  required int pollId,
  required List<int> pollOptionIds,
  OnPollCallback? onCompleted,
}) async {
  Poll poll = await _sdk.api
      .send(
    PollVoteRequest(
      pollId: pollId,
      pollOptionIds: pollOptionIds,
      channelUrl: channelUrl,
      channelType: channelType,
    ),
  )
      .onError((error, stackTrace) {
    if (onCompleted != null) {
      onCompleted(null, SBError(message: "Failed voting poll"));
    }
    throw SBError(message: "Failed voting poll");
  });
  if (onCompleted != null) {
    onCompleted(poll, null);
  }
  return poll;
}