unique_device_identifier 2.0.0 copy "unique_device_identifier: ^2.0.0" to clipboard
unique_device_identifier: ^2.0.0 copied to clipboard

A Flutter plugin that provides a unique device identifier on all platforms including Android, iOS, Windows, macOS, Linux, Web.

unique_device_identifier #

A Flutter plugin that provides a unique device identifier on all platforms including Android, iOS, Windows, macOS, Linux, Web.


✨ Features #

  • 📱 Android: Uses Settings.Secure.ANDROID_ID
  • 🍎 iOS: Uses UIDevice.identifierForVendor
  • 💻 macOS: Uses IOPlatformUUID via IOKit
    • Automatically uses kIOMainPortDefault on macOS 12+ (no deprecation warning)
    • Falls back to kIOMasterPortDefault for compatibility with macOS 11 and earlier
  • 🐧 Linux: Reads /etc/machine-id
  • 🪟 Windows: Reads registry value MachineGuid
  • 🌐 Web:
    • Attempts to generate a fingerprint-based hash from browser characteristics
    • Falls back to a random UUID if fingerprinting fails
    • Stores the identifier in localStorage

🚀 Getting Started #

Add the dependency to your pubspec.yaml:

dependencies:
  unique_device_identifier: ^2.0.0

✅ Usage #

import 'package:unique_device_identifier/unique_device_identifier.dart';

void main() async {
  final deviceId = await UniqueDeviceIdentifier.getUniqueIdentifier();
  print("Device ID: $deviceId");
}

📦 Supported Platforms #

Platform Method
Android Settings.Secure.ANDROID_ID
iOS UIDevice.identifierForVendor
macOS IOPlatformUUID (via IOKit with macOS version fallback)
Linux /etc/machine-id
Windows Registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid
Web localStorage with fingerprint fallback

🔒 Notes #

  • On iOS and Android, the UUID may change after uninstalling and reinstalling the app.
  • On Web, UUID is stored in localStorage and may be cleared manually by the user.
  • macOS implementation avoids deprecated APIs on macOS 12+.
  • No external packages (like uuid or device_info_plus) are used.

🛠 Development #

This plugin uses MethodChannel to communicate with native code.

Each platform implements get_unique_identifier using platform-specific APIs, and the Web implementation is written in Dart using dart:js_interop.


📄 License #

MIT License

1
likes
140
points
99
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin that provides a unique device identifier on all platforms including Android, iOS, Windows, macOS, Linux, Web.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface, web

More

Packages that depend on unique_device_identifier