0

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.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
test t
  • 1
  • 2

1 Answers1

2

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;
Aloysius Samuel
  • 1,004
  • 6
  • 11