Reputation: 11
I need to get android mobile IMEI number using Dart language in Flutter. How to get this slot1 or slot2 IMEI number from Android mobiles.
Upvotes: 1
Views: 2731
Reputation: 1200
You could use device_information package. For this package to use you need to ask for phone permission from the user. So add the below permission in your Manifest file.
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
The second step is to get the user's permission to access their phone's info. Check the below code for permission:
Future<String> _askingPhonePermission() async {
final PermissionStatus permissionStatus = await _getPhonePermission();
}
Future<PermissionStatus> _getPhonePermission() async {
final PermissionStatus permission = await Permission.phone.status;
if (permission != PermissionStatus.granted &&
permission != PermissionStatus.denied) {
final Map<Permission, PermissionStatus> permissionStatus =
await [Permission.phone].request();
return permissionStatus[Permission.phone] ??
PermissionStatus.undetermined;
} else {
return permission;
}
}
And finally, use the above-mentioned package to extract the device's IMEI number.
String imeiNo = await DeviceInformation.deviceIMEINumber;
Upvotes: 3