votePoll method
Future<PollVoteEvent>
votePoll({
- required int pollId,
- required List<
int> pollOptionIds, - OnPollVoteEventCallback? onCompleted,
Cast/ Cancel Poll Vote
Implementation
Future<PollVoteEvent> votePoll({
required int pollId,
required List<int> pollOptionIds,
OnPollVoteEventCallback? onCompleted,
}) async {
final cmd = Command.buildVotePoll(
requestId: Uuid().v1(),
channelType: channelType,
channelUrl: channelUrl,
pollId: pollId,
pollOptionIds: pollOptionIds,
);
try {
var result = await _sdk.cmdManager.sendCommand(cmd);
if (result == null)
throw SBError(
message: "ERROR: NULL returned from VotePoll sendCommand");
PollVoteEvent event = PollVoteEvent.fromJson(result.payload);
if (onCompleted != null) {
onCompleted(event, null);
}
return event;
} catch (exception) {
logger.e(StackTrace.current, [exception]);
if (onCompleted != null)
onCompleted(
null, SBError(message: "Failed sending Vote Poll Request."));
throw (SBError(message: "Failed sending Vote Poll Request."));
}
}