fluttercommunity / fluttercommunity/community
How can we retrieve the dual SIM numbers from the device in Flutter?
- Dominant language
- No language data
- Stars
- 1.7k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
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 initMobileNumberState() async { if (!await MobileNumber.hasPhonePermission) { await MobileNumber.requestPhonePermission; return; }
try {
// String _mobileNumber = (await MobileNumber.mobileNumber)!;
// toastMessage(text: "Mobile : $_mobileNumber");
List? 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.