get static method Null safety

Future<Poll> get(
  1. {required PollRetrievalParams params,
  2. OnPollCallback? onCompleted}
)

Get Poll

Implementation

static Future<Poll> get({
  required PollRetrievalParams params,
  OnPollCallback? onCompleted,
}) async {
  final sdk = SendbirdSdk().getInternal();
  var poll = await sdk.api
      .send(PollGetRequest(
    channelUrl: params.channelUrl,
    pollId: params.pollId,
    channelType: params.channelType,
  ))
      .onError((error, stackTrace) {
    if (onCompleted != null) {
      onCompleted(null, SBError(message: 'Failed Getting Poll'));
    }
    throw SBError(message: 'Failed Getting Poll');
  });

  if (onCompleted != null) {
    onCompleted(poll, null);
  }

  return poll;
}