get static method Null safety

Future<PollOption> get(
  1. {required PollOptionRetrievalParams params,
  2. OnPollOptionCallback? onCompleted}
)

Get Poll Options

Implementation

static Future<PollOption> get({
  required PollOptionRetrievalParams params,
  OnPollOptionCallback? onCompleted,
}) async {
  final sdk = SendbirdSdk().getInternal();
  PollOption option = await sdk.api
      .send(PollOptionGetRequest(
    channelType: params.channelType,
    channelUrl: params.channelUrl,
    pollOptionId: params.pollOptionId,
    pollId: params.pollId,
  ))
      .onError((error, stackTrace) {
    if (onCompleted != null) {
      onCompleted(null, SBError(message: "Failed getting poll option"));
    }
    throw SBError(message: "Failed getting poll option");
  });

  if (onCompleted != null) {
    onCompleted(option, null);
  }
  return option;
}