getGoalByPercentage function

Future<List> getGoalByPercentage()

Implementation

Future<List> getGoalByPercentage()async{
  List userRecords = [];
  //total amount in the account
  int totalAmount = await getIncomes();
  final results = await getRecords("goals");
  List items = results.items;
  for (var element in items) {
    userRecords.add({
      "name":element.data['name'],
      "color":element.data['color'],
      "amount": (int.parse(element.data['amount'].toString())*100)/totalAmount.roundToDouble()
    });
  }
  print(userRecords);
  return userRecords;
}