m8ty_device_info
Flutter package that provides device information including device IDs, user agents, screen resolution, and package info across all platforms (Android, iOS, Web, macOS, Windows, Linux).
Initialization
Section titled “Initialization”Always call initialize() before using any other method:
import 'package:m8ty_device_info/m8ty_device_info.dart';
await M8tyDeviceInfo.initialize();API Surface
Section titled “API Surface”| Method | Description |
|---|---|
getDeviceId() |
Persistent device ID (generated once, stored in SharedPreferences) |
getUserAgent() |
Platform-specific user agent string |
getPackageInfo() |
App name, version, build number |
getSystemDetails() |
Combined system details map |
getScreenResolution() |
Screen resolution as Size |
getAndroidSdkInt() |
Android SDK version (null on non-Android) |
final deviceInfo = M8tyDeviceInfo.instance;
// Persistent device ID (generated once, stored in SharedPreferences)final deviceId = await deviceInfo.getDeviceId();
// Platform-specific user agent stringfinal userAgent = await deviceInfo.getUserAgent();
// Package info (app name, version, build number)final packageInfo = await deviceInfo.getPackageInfo();
// Combined system details mapfinal details = await deviceInfo.getSystemDetails();
// Screen resolutionfinal size = deviceInfo.getScreenResolution();
// Android SDK version (null on non-Android)final sdkInt = await deviceInfo.getAndroidSdkInt();Key Rules
Section titled “Key Rules”- Use
M8tyDeviceInfo.instance— never construct it directly. - Results for
getDeviceId()andgetUserAgent()are cached in memory after the first call. getDeviceId()generates a UUID-based 16-character ID on first use and persists it viaSharedPreferences.- Use
M8tyDeviceInfo.clearCache()only in tests or when device info may have changed.
© m8ty GmbH 2023 · m8ty.eu
