From 4fa6053e8fe6598c264e786b489d91e495cf8640 Mon Sep 17 00:00:00 2001 From: CyberWake Date: Sat, 23 Nov 2024 17:54:22 +0530 Subject: [PATCH] fix: handle exception for requestPhoneHint method channel call. --- lib/sms_autofill.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/sms_autofill.dart b/lib/sms_autofill.dart index 75a33de..5863ce9 100644 --- a/lib/sms_autofill.dart +++ b/lib/sms_autofill.dart @@ -30,8 +30,12 @@ class SmsAutoFill { if ((defaultTargetPlatform == TargetPlatform.android || defaultTargetPlatform == TargetPlatform.iOS) && !kIsWeb) { - final String? hint = await _channel.invokeMethod('requestPhoneHint'); - return hint; + // adding try catch block to handle any exception thrown from method + // channel call. + try { + final String? hint = await _channel.invokeMethod('requestPhoneHint'); + return hint; + } catch (_) {} } return null; }