how to get unique device id in flutter?

At the point when we talk about a special gadget id in local, we are having Settings.Secure.ANDROID_ID to get a one of a kind gadget id. So in this, we will discuss How to get a Unique Device id in Flutter?

How to get unique device id for both Android and IOS in flutter?

  • In your pubspec.yaml record add this:
  device_info: ^0.4.0+4
  • Add import in your group.
import 'package:device_id/device_id.dart';

The accompanying code piece tells the best way to get gadget id.

static Future<List<String>> getDeviceDetails() async {
    String deviceName;
    String deviceVersion;
    String identifier;
    final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
    try {
      if (Platform.isAndroid) {
        var build = await deviceInfoPlugin.androidInfo;
        deviceName = build.model;
        deviceVersion = build.version.toString();
        identifier = build.androidId;  //UUID for Android
      } else if (Platform.isIOS) {
        var data = await deviceInfoPlugin.iosInfo;
        deviceName =;
        deviceVersion = data.systemVersion;
        identifier = data.identifierForVendor;  //UUID for iOS
    } on PlatformException {
      print('Failed to get platform version');
//if (!mounted) return;
return [deviceName, deviceVersion, identifier];

Clients can store this UUID in the Keychain. This way you can set an interesting ID for your gadget.

Client can likewise make a capacity like the beneath:

Future<String> _getId() async {
  var deviceInfo = DeviceInfoPlugin();
  if (Platform.isIOS) { // import 'dart:io'
    var iosDeviceInfo = await deviceInfo.iosInfo;
    return iosDeviceInfo.identifierForVendor; // unique ID on iOS
  } else {
    var androidDeviceInfo = await deviceInfo.androidInfo;
    return androidDeviceInfo.androidId; // unique ID on Android


String deviceId = await _getId();


_getId().then((id) {
  String deviceId = id;


In this article, we have been through How to get a Unique Device id in Flutter.

Still, need support for Flutter? We are always there to serve you better.

Keep Fluttering !!!
Keep Learning !!!

Also Read

Leave a Comment