Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Device ID in Flutter: device_info_plus package returns null when requesting androidId

I'm a new Flutter developer, I'm about to develop a Flutter app which needs to use device id so I decided to use the device_info_plus package to get androidId, but when I request device info in order to get androidId within it, it returns null and also does not even exist in toMap() object. I don't know exactly what happened but all the documentation I went through says that this package could give me the device id.

Here is the function

Future<Object?> getId() async {
    var deviceInfo = DeviceInfoPlugin();
    if (Platform.isIOS) { // import 'dart:io'
      var iosDeviceInfo = await deviceInfo.iosInfo;
      return iosDeviceInfo.identifierForVendor; // unique ID on iOS
    } else if(Platform.isAndroid) {
      var androidDeviceInfo = await deviceInfo.androidInfo;
      print(androidDeviceInfo.androidId);
      return androidDeviceInfo.androidId; // unique ID on Android
    }
    return false;
  }
like image 258
Deogratius Mabima Avatar asked Feb 11 '26 09:02

Deogratius Mabima


1 Answers

androidId functionality was removed from version 4.0.0. You can see it from the Changelog here.

If you'd like to get androidId, you need to downgrade device_info_plus in pubspec.yaml

device_info_plus: 3.2.4

P.S. There is the issue on Github that you can upvote. Probably this functionality will be returned.

like image 92
Katarina Sheremet Avatar answered Feb 16 '26 08:02

Katarina Sheremet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!