getVotes method

Future<bool> getVotes({
  1. String? localPath,
  2. String? remotePath,
  3. ScrutinFromJson? downloaded,
  4. bool? hiliteFronde,
  5. String? amendementString,
})

used by drawVoteHemicycleFromPath FutureBuilder

Implementation

Future<bool> getVotes(
    {String? localPath,
    String? remotePath,
    ScrutinFromJson? downloaded,
    bool? hiliteFronde,
    String? amendementString}) async {
  if (localPath != null || remotePath != null) {
    ReturnFromJson? _return = await OpenAssembleeJsonTranscoder()
        .getJsonScrutin(
            localPath: localPath,
            remotePath: remotePath,
            amendementPath: amendementString);
    if (_return != null) {
      scrutin = _return.scrutin;
      if (_return.amendement != null) {
        amendement = _return.amendement;
      }
    }
  } else if (downloaded != null) {
    scrutin = downloaded;
  }

  if (scrutin != null) {
    if (scrutin!.groupVotesDetails != null) {
      List<GroupVotesFromJson> _reorder = scrutin!.groupVotesDetails!;
      _reorder.sort();
      for (GroupVotesFromJson group in _reorder) {
        nbOfMembersInvolved += group.nbMembers ?? 0;
        _localGroups.add(GroupSectors(group.nbMembers ?? 0, group.groupColor,
            description: group.groupName));
        _localInterGroups.add(GroupSectors(
            group.nbMembers ?? 0, group.intergroupColor,
            description: group.intergroupName));
      }
    }
    votesAssemblyTest = await OpenAssembleeJsonTranscoder()
        .getJsonIndividualVotes(scrutin!, hiliteFronde);

    return true;
  }

  return false;
}