Closed dk-a-dev closed 3 months ago
I made a workaround for this issue..
I know it's not that excellent, but it worked for me 😅
For the code in the example, you can add a Timer
and a String
this way:
Timer? smsGrouper;
String finalSMS = '';
_plugin.smsStream.listen((event) {
smsGrouper?.cancel();
finalSMS += event.body;
smsGrouper = Timer(const Duration(seconds: 3), () {
setState(() {
sms = finalSMS;
sender = event.sender;
time = event.timeReceived.toString();
});
finalSMS = '';
});
});
The Timer
waits 3 seconds to group the SMS part with next one before dealing with the SMS. If the duration passed without receiving any new part, it assumes that the SMS has finished.
You may change the duration due to your needs,
Thanks Bud
Reads the last few characters of the message(SMS) only @Ayush783 I will be grateful if u can fix this or give any alternate solution