You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to retrieve the user's mobile number in Android. I am using the 'mobile_number' package to obtain dual SIM numbers from the device in Android. However, with this package, I am only able to retrieve the number for SIM 1.
I have used the following code, but I am not obtaining the number.
@override void initState() {
MobileNumber.listenPhonePermission((isPermissionGranted)
{
if (isPermissionGranted)
{ initMobileNumberState(); }
else {}
});
initMobileNumberState();
super.initState();}
Future<void> initMobileNumberState() async { if (!await MobileNumber.hasPhonePermission) { await MobileNumber.requestPhonePermission; return; }
try {
// String _mobileNumber = (await MobileNumber.mobileNumber)!;
// toastMessage(text: "Mobile : $_mobileNumber");
List<SimCard>? simCards = await MobileNumber.getSimCards;
for (SimCard simCard in simCards!)
{
print("Carrier: ${simCard.carrierName}");
print("Country: ${simCard.countryIso}");
print("Number: ${simCard.number}");
}
}
on PlatformException catch (e) {
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {});
}
I expect to retrieve both SIM numbers from the device.
The text was updated successfully, but these errors were encountered:
hemanta321
changed the title
How we get dual sim number from the device in flutter
How can we retrieve the dual SIM numbers from the device in Flutter?
Jan 3, 2024
I want to retrieve the user's mobile number in Android. I am using the 'mobile_number' package to obtain dual SIM numbers from the device in Android. However, with this package, I am only able to retrieve the number for SIM 1.
I have used the following code, but I am not obtaining the number.
I expect to retrieve both SIM numbers from the device.
The text was updated successfully, but these errors were encountered: