Help Instance Help

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

Always call initialize() before using any other method:

import 'package:m8ty_device_info/m8ty_device_info.dart'; await M8tyDeviceInfo.initialize();

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)

Usage

final deviceInfo = M8tyDeviceInfo.instance; // Persistent device ID (generated once, stored in SharedPreferences) final deviceId = await deviceInfo.getDeviceId(); // Platform-specific user agent string final userAgent = await deviceInfo.getUserAgent(); // Package info (app name, version, build number) final packageInfo = await deviceInfo.getPackageInfo(); // Combined system details map final details = await deviceInfo.getSystemDetails(); // Screen resolution final size = deviceInfo.getScreenResolution(); // Android SDK version (null on non-Android) final sdkInt = await deviceInfo.getAndroidSdkInt();

Key Rules

  • Use M8tyDeviceInfo.instance — never construct it directly.

  • Results for getDeviceId() and getUserAgent() are cached in memory after the first call.

  • getDeviceId() generates a UUID-based 16-character ID on first use and persists it via SharedPreferences.

  • Use M8tyDeviceInfo.clearCache() only in tests or when device info may have changed.

03 June 2026