getVotesByOptionId method

Future<List<PollVoteModel>> getVotesByOptionId(
  1. dynamic optionId
)

Implementation

Future<List<PollVoteModel>> getVotesByOptionId(optionId) {
  Log(
    logName: 'GetVotesByOptionId',
    className: 'Poll',
    methodName: 'getVotesByOptionId',
    type: 'INFO',
    text:
        '{event: Get Votes By Option Id, user: ${currentUser?.userPayloadId}, user is ${currentUser?.firstName} ${currentUser?.lastName}, option id: $optionId',
  );
  return _httpService.getVotesByOptionId(optionId).then((data) async {
    if (data.statusCode == 200) {
      List<dynamic> votes = json.decode(data.body);
      List<PollVoteModel> votesList =
          votes.map((i) => PollVoteModel.fromJson(i)).toList();
      return votesList;
    } else {
      return List<PollVoteModel>.from([]);
    }
  });
}