imei_getter 0.3.0
imei_getter: ^0.3.0 copied to clipboard
A Flutter plugin to get device identifiers (IMEI on older Android, ANDROID_ID on newer Android, identifierForVendor on iOS) with proper permission handling.
IMEI Getter Plugin #
A robust Flutter plugin to retrieve unique device identifiers across Android and iOS platforms. It handles permission requests, Android API level differences, and iOS specifics to provide the most reliable identifier available.

Why is this important? #
In mobile development, uniquely identifying a device is crucial for various use cases such as:
- Fraud Prevention: detecting multiple accounts created from the same device.
- Licensing: binding a software license to a specific device.
- Analytics: tracking unique installs and user retention.
However, accessing hardware identifiers like IMEI has become increasingly restricted due to privacy changes in modern OS versions (Android 10+, iOS). This plugin abstracts away the complexity of checking API levels and permissions, providing a seamless fallback mechanism to ensure you always get a valid identifier.
Features #
- Smart Fallback: Automatically tries to get IMEI (on older Android), falls back to
ANDROID_IDon newer Android, and usesidentifierForVendoron iOS. - Detailed Info: Returns not just the ID but also its type (
IMEI,ANDROID_ID,IDFV) so you know what you are working with. - Tablet Support: Safely handles devices without telephony features (tablets) by falling back to
ANDROID_IDinstead of crashing. - Permission Handling: Built-in methods to check and request
READ_PHONE_STATEpermission on Android.
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
imei_getter: ^0.3.0
Usage #
Import the package #
import 'package:imei_getter/imei_getter.dart';
Get Device Identifier (Simple) #
String? id = await ImeiGetter.getDeviceIdentifier();
print('Device ID: $id');
Get Device Identifier with Type Info (Recommended) #
DeviceIdentifier? data = await ImeiGetter.getDeviceIdentifierWithInfo();
if (data != null) {
print('ID: ${data.id}');
print('Type: ${data.type}'); // DeviceIdentifierType.imei, .androidId, or .idfv
}
Handle Permissions (Android) #
// Check if permission is granted
bool hasPermission = await ImeiGetter.hasPermission();
if (!hasPermission) {
// Request permission
await ImeiGetter.requestPermission();
}
Platform Specifics #
| Platform | Identifier Returned | Notes |
|---|---|---|
| Android < 10 | IMEI (Primary) or ANDROID_ID (Fallback) | Requires READ_PHONE_STATE permission for IMEI. |
| Android 10+ | ANDROID_ID | IMEI access is restricted by OS. No permission needed. |
| iOS | identifierForVendor (IDFV) | Unique to vendor. Resets if all vendor apps are uninstalled. |
Author #
Godfrey Lebo
- Email: [email protected]
- GitHub: emorilebo
- Website: godfreylebo.dev
License #
This project is licensed under the MIT License - see the LICENSE file for details.