addPollOption method

Future<Poll> addPollOption({
  1. required int pollId,
  2. required String optionText,
  3. OnPollCallback? onCompleted,
})

Add Poll Option

Implementation

Future<Poll> addPollOption({
  required int pollId,
  required String optionText,
  OnPollCallback? onCompleted,
}) async {
  Poll poll = await _sdk.api
      .send(
    PollOptionAddRequest(
      pollId: pollId,
      text: optionText,
      channelUrl: channelUrl,
      channelType: channelType,
    ),
  )
      .onError((error, stackTrace) {
    if (onCompleted != null) {
      onCompleted(null, SBError(message: 'Failed adding poll option'));
    }
    throw SBError(message: "Failed adding poll option");
  });
  if (onCompleted != null) {
    onCompleted(poll, null);
  }
  return poll;
}