getOptionsByQuestionId method

Future<List<PollOptionModel>> getOptionsByQuestionId(
  1. dynamic questionId
)

Implementation

Future<List<PollOptionModel>> getOptionsByQuestionId(questionId) {
  Log(
    logName: 'GetOptionsByQuestionId',
    className: 'Poll',
    methodName: 'getOptionsByQuestionId',
    type: 'INFO',
    text:
        '{event: Get Options By Question Id, user: ${currentUser?.userPayloadId}, user is ${currentUser?.firstName} ${currentUser?.lastName}, question id: $questionId',
  );
  return _httpService.getOptionsByQuestionId(questionId).then((data) async {
    if (data.statusCode == 200) {
      List<dynamic> options = json.decode(data.body);
      List<PollOptionModel> optionsList =
          options.map((i) => PollOptionModel.fromJson(i)).toList();
      return optionsList;
    } else {
      return List<PollOptionModel>.from([]);
    }
  });
}