calculateMessages function

Future<Map<String, dynamic>> calculateMessages()

Implementation

Future<Map<String, dynamic>> calculateMessages() async {
  Map messages={};
  const String api = "/calculate_messages";
  final messageRecords = await getRecords("mobileMoney");
  messageRecords.items.forEach((element) async {
    messages = element.data['messages'] as Map;

  });
  print({"msg": messages});
  final response = await dio.post(api, data: {"msg": messages});
  if(response.statusCode==200){
    await showMsgSuccess("Mobile Money", "Successfully calculated and analysed");

    await addCalMessage({
      "data":response.data
    });
  }
  print(response.data);
  return response.data;
}