adarshbalu/twilio_flutter

I am trying to send sms in trial version but facing Unhandled Exception: Exception

Closed this issue · 3 comments

I am using this plugin for sending sms in trial version. Whenever I try to send sms to different number other than I added in console, I got an exception which I am unable to handle, I tried wrapping with try, catch block of My code when sending sms so i can catch the exception but failed.
Whenever I call twilioFlutter.sendSMS method I got an exception and my app crashes.
Here is my Code:
try {
twilioFlutter.sendSMS(
toNumber: phoneNumber,
messageBody: 'Irfan Sadiq is sending message and your code is $otp');
} catch (e) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text('Something went wrong')));
}
Any help, fixes will be highly appreciated.
Thanks

@irfansadiq786
Please check if sendSMS is a future function. If so you'll have to add catchError method to catch exceptions. Or else add an await while calling sendSMS function inorder to get exceptions inside try-catch.

Hi @irfansadiq786, will be taking up Exception handling in the next update.

This issue is fixed.