I want to uniquely identify a hardware device. How do I get the unique device ID in Flutter? I am using the device-info-plus plugin, but it doesn’t give an Android ID in recent versions. I will have to downgrade to a very old version for Android ID, and it’s causing other dependency issues, so I can’t do that.
This is my current code, but multiple users are getting the same device ID because of this:
if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
deviceId = androidInfo.id;
print('Running on ${androidInfo.id}');
}
Is there any way to get the unique device ID in Flutter? Please help, as it’s causing a major issue in our live project.
2
Answers
Your approach is good with "https://pub.dev/packages/device_info_plus" however, there is no guarantee that the Id is truly unique and may vary depending on what the phone is going through. The ideal would be to combine this practice with the user’s unique id or the Wifi mac address or something else.
This is not direct way for flutter to get device id. Using native to get user Device ID Get succesfully.
this is new package android code:
and this is package Lib file code. Create a method channel.
This is flutter code.