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
- 🔒 Security Checks: Detect debug mode, USB debugging, debugger attachment, and hooking frameworks (Xposed, Frida, Substrate)
- 📊 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.6.0Then run:
flutter pub get- 🔒 Enhanced Security: Comprehensive security checks following OWASP Mobile Top 10 2024-2025 standards
- Debug mode detection (build configuration check)
- USB debugging detection (ADB and development settings)
- Debugger attachment detection (runtime debugger check)
- Hook framework detection (Xposed, Frida, Substrate, Cycript)
- Optimized /proc/self/maps scanning for better performance
- 🌐 Web Support: Full web platform implementation with browser and OS detection using
package:web - ✅ Improved Detection: More reliable GMS/HMS detection with package verification
- 🚀 Modern APIs: Migrated to
package:web(v1.1.0+) for better web support - 🔧 Better Error Handling: Resource leak fixes, improved exception handling
- ⚡ Performance: Optimized file reading for large proc files, buffered I/O operations
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}');
// Security checks
print('Debug Mode: ${deviceInfo.isDebugMode}');
print('Rooted: ${deviceInfo.isRooted}');
print('Hook Detected: ${deviceInfo.isHookDetected}');
// 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 rootedisDebugMode- Whether app is running in debug modeisUsbDebuggingEnabled- Whether USB debugging is enabledisDebuggerAttached- Whether debugger is attached to the processisHookDetected- Whether hooking frameworks are detected (Xposed, Frida, Substrate)
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=== Security Status ===');
print('Debug Mode: ${info.isDebugMode}');
print('USB Debugging: ${info.isUsbDebuggingEnabled}');
print('Debugger Attached: ${info.isDebuggerAttached}');
print('Hook Detected: ${info.isHookDetected}');
print('\n=== Mobile Services ===');
print('Google Services: ${info.isGMS}');
print('Huawei Services: ${info.isHMS}');
print('HarmonyOS: ${info.isHMOS}');
} 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();
}
}void checkSecurity() async {
final info = await DeviceHelpers.getInfo();
print('\n=== Security Status ===');
print('Debug Mode: ${info.isDebugMode}');
print('USB Debugging: ${info.isUsbDebuggingEnabled}');
print('Debugger Attached: ${info.isDebuggerAttached}');
print('Hook Detected: ${info.isHookDetected}');
print('Rooted: ${info.isRooted}');
// Check for security risks
if (info.isDebugMode || info.isUsbDebuggingEnabled ||
info.isDebuggerAttached || info.isHookDetected || info.isRooted) {
print('⚠️ Security warning: Device may be compromised');
// Implement your security logic here
}
}The plugin implements OWASP Mobile Top 10 compliant security checks:
Android:
- Debug Mode: Checks
ApplicationInfo.FLAG_DEBUGGABLEflag - USB Debugging: Checks both
ADB_ENABLEDandDEVELOPMENT_SETTINGS_ENABLED - Debugger Attached: Uses
Debug.isDebuggerConnected()API - Root Detection: RootBeer library + custom checks (Magisk, test-keys, su binaries)
- Hook Detection:
- Xposed/LSPosed: Class loading, file system checks, system properties
- Frida: Process scanning, /proc/self/maps analysis (optimized buffered reading)
- Substrate: Library detection
- General: Pattern matching in loaded libraries
iOS:
- Debug Mode:
#if DEBUG+ bundle path check - Developer Mode: Provisioning profile detection
- Debugger Attached: sysctl with P_TRACED flag check
- Jailbreak Detection: Cydia, Sileo, sandbox integrity, URL schemes, dynamic libraries
- Hook Detection:
- Frida: dyld image scanning
- Substrate/Cycript: Library detection
- General: Pattern matching in loaded images
Important Notes:
- All checks are client-side and can be bypassed
- Use in combination with server-side validation
- Consider Firebase App Check for backend protection
- Update regularly as bypass techniques evolve
| Feature | Android | iOS | Web |
|---|---|---|---|
| Device Info | ✅ | ✅ | ✅ (Limited) |
| OS Detection | ✅ | ✅ | ✅ |
| Browser Detection | ❌ | ❌ | ✅ |
| Tablet Detection | ✅ | ✅ | ✅ |
| Manufacturer Detection | ✅ | ✅ | ✅ (Limited) |
| IDFA | ❌ | ✅ | ❌ |
| Badge Update | ❌ | ✅ | ❌ |
| Settings Navigation | ✅ | ✅ | ❌ |
| Emulator Detection | ✅ | ✅ | ❌ |
| Root Detection | ✅ | ✅ | ❌ |
| Security Checks | ✅ | ✅ |
On web platform, the following information is available:
Available:
- OS detection (Windows, macOS, Linux, Android, iOS)
- Browser type (Chrome, Safari, Firefox, Edge, Opera)
- OS version
- Tablet detection (based on screen size and user agent)
- Manufacturer detection (limited, based on user agent)
- Debug mode detection (checks for localhost/127.0.0.1)
Not Available:
- Root/Jailbreak detection
- Emulator detection
- GMS/HMS availability
- USB debugging detection
- Debugger attached detection
- Hook framework detection
- IDFA/Advertising ID
- Settings navigation
- Badge management
Example Web Output:
DeviceInfo(
os: 'windows', // Detected from user agent
osVersion: '10.0', // Windows version
manufacturer: 'Unknown', // Limited detection
brand: 'Chrome', // Browser name
model: 'Chrome on WINDOWS', // Browser + OS
isTablet: false, // Screen-based detection
isDebugMode: true, // localhost detection
// All security flags are false on web
)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.