my_device_info
my_device_info provides privacy-aware, typed Android and iOS diagnostics.
Version 0.2.0 can collect a complete snapshot with one native call while
keeping the app-scoped identifier opt-in. It targets Flutter 3.47 and Dart
3.13.
Highlights
- One-call
DeviceInfoSnapshotAPI instead of multiple platform round trips. - Typed platform and operating-system information.
- Model identifier, CPU architecture, supported ABIs, physical-device hint, and Android low-RAM status.
- App-scoped identifier excluded by default and redacted from JSON by default.
- A replaceable platform interface for tests and future platform packages.
- All 0.1.0 getters remain source-compatible.
Supported platforms
| Platform | Minimum version | Identifier source |
|---|---|---|
| Android | API 24 | Settings.Secure.ANDROID_ID |
| iOS | 15.0 | UIDevice.identifierForVendor |
No runtime permission is required. The identifier is scoped by the operating
system; it is not an IMEI, advertising ID, or permanent account identifier.
Android scopes ANDROID_ID to the signing key, user, and device on API 26+.
iOS shares identifierForVendor between apps from the same vendor. Both values
can change, so applications must not treat them as permanent identity.
Installation
dependencies:
my_device_info: ^0.2.0
Then run:
flutter pub get
Usage
import 'package:flutter/services.dart';
import 'package:my_device_info/my_device_info.dart';
Future<void> loadDeviceInfo() async {
try {
final DeviceInfoSnapshot info = await MyDeviceInfo.getInfo();
print(info.platform);
print(info.operatingSystem.version);
print(info.model);
print(info.architecture);
print(info.supportedAbis);
print(info.isPhysicalDevice);
// JSON output excludes the app-scoped identifier.
final Map<String, Object?> diagnostics = info.toJson();
} on PlatformException catch (error) {
// Handle a platform failure here.
}
}
Request the app-scoped identifier only for a feature that actually needs it:
final DeviceInfoSnapshot info = await MyDeviceInfo.getInfo(
includeDeviceIdentifier: true,
);
final String? identifier = info.deviceIdentifier;
final safeJson = info.toJson(); // Still excludes deviceIdentifier.
final fullJson = info.toJson(includeDeviceIdentifier: true);
Do not use the identifier as an authentication secret, advertising identifier,
or permanent user identity. Avoid sending fullJson to logs or analytics by
default. deviceName is platform-provided and can also contain a user-selected
name.
Legacy getters
The static getters from 0.1.0 remain available, including platformVersion,
deviceIdentifier, deviceModel, deviceManufacturer, apiLevel,
deviceName, productName, cpuName, and hardware. apiLevel still returns
an int on Android and the system-version String on iOS for compatibility.
Migrating from 0.1.0
- Prefer
MyDeviceInfo.getInfo()when reading more than one field. - Use the typed
operatingSystem.androidApiLevelinstead of the legacy dynamicapiLevelgetter. - Enable
includeDeviceIdentifieronly at the point where it is required. - JSON serialization now makes identifier inclusion an explicit second opt-in.
Migrating from 0.0.x
- Replace
MyDeviceInfo.deviceIMEINumberwithMyDeviceInfo.deviceIdentifier. The legacy getter is deprecated and now aliases the app-scoped identifier. - Remove
READ_PHONE_STATEand any phone permission prompt that existed only for this package. - Android now requires API 24 or later; iOS now requires 15.0 or later.
Development
See doc/OPERATIONS.md for the validation and release commands used by this repository.