getUserMsg function
Implementation
Future<Map<String,dynamic>> getUserMsg() async {
// final handler = Permission.sms.request();
// bool granted = await handler.isGranted;
int count = 0;
List resultMsg = [];
// if(granted==true){
for (var e in address) {
List<SmsMessage> results = await query.querySms(address: e);
results.forEach((i) {
count++;
resultMsg.add({"msg": i.body, "address": i.address,"date":"${i.date!.year}-${i.date!.month}-${i.date!.day}","time":"${i.date!.hour}:${i.date!.minute}:${i.date!.second}"});
print(i.body);
print(i.address);
});
}
// }
if(count==resultMsg.length){
extractMessages({
"messages":resultMsg
});
// print(resultMsg)
}
return {
"messages":resultMsg
};
}