In my flutter app, I want to implement one feature, that when the app will be open, it will initially print the mobile number(considering there is single or multiple SIM card in the device) of the Android device in which the app is running.
I am not sure whether it is possible or not. If possible please let me know the details procedure with required code and configuration.
Note that: I have tried using some of the plugins/packages of flutter given below:
https://pub.dev/packages/sms_autofill
https://pub.dev/packages/mobile_number
https://pub.dev/packages/sim_data
But none of these solution worked for me. Please help to have a solution of this issue?
2
Answers
The truth is, it’s not really possible to reliably retrieve the mobile number of an Android device from within a Flutter app. Here’s why:
Privacy restrictions: Modern Android versions have significantly tightened security around accessing sensitive information like phone numbers. This is a deliberate design choice to protect user privacy.
Inconsistent behavior: Even if you use packages that claim to retrieve the phone number, they often rely on workarounds or deprecated APIs. These methods are unreliable and may work on some devices but fail on others.
User permissions: Even if a method exists, it typically requires explicit user permission. Many users are (rightfully) hesitant to grant such sensitive permissions, especially for features that don’t seem essential to the app’s core functionality.
iOS incompatibility: On iOS, there’s no API to programmatically access the device’s phone number, so any solution would be Android-only at best.
Future-proofing issues: As Android continues to evolve, any workarounds that currently exist are likely to be blocked in future updates, breaking your app’s functionality.
Given these constraints, it’s generally not feasible or advisable to try to automatically retrieve the device’s phone number in a Flutter app. Instead, it’s better to:
In summary, while it might seem like a straightforward task, reliably getting the device’s phone number is not really possible in a way that’s consistent, future-proof, and respectful of user privacy. It’s best to explore other options for whatever functionality you’re trying to implement.
Unfortunately, there is no way to do for now. And I think that it would be the same in the future.
BTW, alternatively, you can choose one of the following two methods if you’d like to acquire the mobile number to make a phone call.