A comprehensive Flutter plugin for device information and utilities across Android, iOS, and Web platforms.
- π± Device Information: Get detailed device specs, manufacturer, model, OS version, and more
- π Device Detection: Detect emulators, tablets, rooted devices, and developer mode
- π Platform Services: Check for Google Mobile Services (GMS), Huawei Mobile Services (HMS), and HarmonyOS
- π― IDFA Support: Request tracking authorization and get Identifier for Advertisers (iOS)
- π Badge Management: Update app badge count with permission handling
- βοΈ Settings Navigation: Open app settings and notification settings directly
Add this to your package's pubspec.yaml
file:
dependencies:
device_helpers: ^1.5.1
Then run:
flutter pub get
import 'package:device_helpers/device_helpers.dart';
// Get comprehensive device information
final deviceInfo = await DeviceHelpers.getInfo();
print('Device: ${deviceInfo.manufacturer} ${deviceInfo.model}');
print('OS: ${deviceInfo.os} ${deviceInfo.osVersion}');
print('Is Emulator: ${deviceInfo.isEmulator}');
// Request IDFA (iOS only)
final status = await DeviceHelpers.requestTrackingAuthorization();
if (status == TrackingRequestStatus.authorized) {
final idfa = await DeviceHelpers.getIdfa();
print('IDFA: $idfa');
}
// Update app badge (iOS only)
final hasPermission = await DeviceHelpers.updateBadgeRequest();
if (hasPermission) {
await DeviceHelpers.badgeUpdate(5);
}
// Open settings
await DeviceHelpers.openAppSettings();
await DeviceHelpers.openAppNotificationSettings();
For IDFA functionality, add the following to your ios/Runner/Info.plist
:
<key>NSUserTrackingUsageDescription</key>
<string>This app needs permission to track activity for advertising purposes.</string>
To support Huawei Mobile Services, add the HMS repository to your android/build.gradle
:
buildscript {
repositories {
google()
mavenCentral()
// Add HMS repository
maven { url 'https://developer.huawei.com/repo/' }
}
}
allprojects {
repositories {
google()
mavenCentral()
// Add HMS repository
maven { url 'https://developer.huawei.com/repo/' }
}
}
Future<DeviceInfo> getInfo()
Returns comprehensive device information including:
manufacturer
- Device manufacturer (Apple, Samsung, etc.)brand
- Device brand (iPhone, Galaxy, etc.)model
- Device model nameuuid
- Unique device identifierappVersion
- App versionappBundle
- App bundle identifierappBuild
- App build numberappName
- App display nameos
- Operating system nameosVersion
- Operating system versionsdkVersion
- SDK versionisEmulator
- Whether running in emulatorisTablet
- Whether device is a tabletisMIUI
- Whether device has MIUI (Xiaomi)isGMS
- Whether Google Mobile Services are availableisHMS
- Whether Huawei Mobile Services are availableisHMOS
- Whether device runs HarmonyOSisTV
- Whether device is a TVisDeveloperModeEnabled
- Whether developer mode is enabledisRooted
- Whether device is rootednumberOfProcessors
- Number of CPU cores
Future<TrackingRequestStatus> requestTrackingAuthorization()
Requests user permission for tracking. Returns:
TrackingRequestStatus.notDetermined
- User hasn't decidedTrackingRequestStatus.restricted
- User is restrictedTrackingRequestStatus.denied
- User denied permissionTrackingRequestStatus.authorized
- User granted permissionTrackingRequestStatus.notSupported
- Tracking not supported
Future<String?> getIdfa()
Gets the Identifier for Advertisers. Requires authorized tracking permission.
Future<bool> updateBadgeRequest()
Requests permission to update app badge count.
Future<void> badgeUpdate(int value)
Updates the app badge count to the specified value.
Future<void> openAppSettings()
Opens the app's settings page in system settings.
Future<void> openAppNotificationSettings()
Opens the app's notification settings page.
void printDeviceInfo() async {
try {
final info = await DeviceHelpers.getInfo();
print('=== Device Information ===');
print('Manufacturer: ${info.manufacturer}');
print('Model: ${info.model}');
print('OS: ${info.os} ${info.osVersion}');
print('App: ${info.appName} (${info.appVersion})');
print('\n=== Device Capabilities ===');
print('Is Emulator: ${info.isEmulator}');
print('Is Tablet: ${info.isTablet}');
print('Is Rooted: ${info.isRooted}');
print('Developer Mode: ${info.isDeveloperModeEnabled}');
print('\n=== Mobile Services ===');
print('Google Services: ${info.isGMS}');
print('Huawei Services: ${info.isHMS}');
print('HarmonyOS: ${info.isHMOS}');
print('\n=== Hardware ===');
print('CPU Cores: ${info.numberOfProcessors}');
} catch (e) {
print('Error getting device info: $e');
}
}
void handleIDFA() async {
// Request tracking authorization
final status = await DeviceHelpers.requestTrackingAuthorization();
switch (status) {
case TrackingRequestStatus.authorized:
final idfa = await DeviceHelpers.getIdfa();
print('IDFA: $idfa');
break;
case TrackingRequestStatus.denied:
print('User denied tracking permission');
break;
case TrackingRequestStatus.notDetermined:
print('User has not decided yet');
break;
case TrackingRequestStatus.restricted:
print('Tracking is restricted');
break;
case TrackingRequestStatus.notSupported:
print('Tracking not supported on this platform');
break;
}
}
void manageBadge() async {
// Request badge permission
final hasPermission = await DeviceHelpers.updateBadgeRequest();
if (hasPermission) {
// Update badge count
await DeviceHelpers.badgeUpdate(10);
print('Badge updated successfully');
// Clear badge
await DeviceHelpers.badgeUpdate(0);
} else {
print('Badge permission denied');
// Optionally open settings
await DeviceHelpers.openAppNotificationSettings();
}
}
Feature | Android | iOS | Web |
---|---|---|---|
Device Info | β | β | β |
IDFA | β | β | β |
Badge Update | β | β | β |
Settings Navigation | β | β | β |
Emulator Detection | β | β | β |
Root Detection | β | β | β |
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.