safe_device 1.3.8 copy "safe_device: ^1.3.8" to clipboard
safe_device: ^1.3.8 copied to clipboard

This package helps to detect iOS Simulator, Android Emulator and Debug Mode. This package also detects MockLocation/Fake GPS location on Android Device. Also check device is real or not.

safe_device (Null-Safety) #

Safe Device Safe Device Flutter (Null-Safety) Jailbroken, root, emulator and mock location detection.

Getting Started #

In your flutter project add the dependency:

dependencies:
...
  safe_device: ^1.3.8
copied to clipboard

Usage #

Importing package

import 'package:safe_device/safe_device.dart';
copied to clipboard

Configuration

You can configure the plugin at startup using SafeDevice.init and SafeDeviceConfig. This is useful if you want to disable automatic check such as the mock location detection.

import 'package:safe_device/safe_device.dart';
import 'package:safe_device/safe_device_config.dart';

void main() async {
  SafeDevice.init(
    SafeDeviceConfig(mockLocationCheckEnabled: false), // disables mock location check on Android
  );
  // ...rest of your app
}
copied to clipboard

It's not mandatory to configure the plugin at the start, if not provided a default configuration with everything enable is provided automatically

Using it

Checks whether device JailBroken on iOS/Android?

bool isJailBroken = await SafeDevice.isJailBroken;
copied to clipboard

(iOS ONLY) Enhanced jailbreak detection with custom path checking

bool isJailBrokenCustom = await SafeDevice.isJailBrokenCustom;
copied to clipboard

(iOS ONLY) Get detailed breakdown of jailbreak detection methods

Map<String, bool> details = await SafeDevice.jailbreakDetails;
copied to clipboard

Checks whether device is real or emulator

bool isRealDevice = await SafeDevice.isRealDevice;
copied to clipboard

bool isMockLocation = await SafeDevice.isMockLocation;

bool isMockLocation = await SafeDevice.isMockLocation;
copied to clipboard

Android: If mock location check is disabled via config, the check always returns false and no location updates are started. If enabled (default), the check is active.

iOS: The config is stored for future use but does not affect current detection logic. Mock location detection on iOS is based on jailbreak/emulator status.

(ANDROID ONLY) Check if application is running on external storage

bool isOnExternalStorage = await SafeDevice.isOnExternalStorage;
copied to clipboard

Check if device violates any of the above

bool isSafeDevice = await SafeDevice.isSafeDevice;
copied to clipboard

(ANDROID ONLY) Check if development Options is enable on device

bool isDevelopmentModeEnable = await SafeDevice.isDevelopmentModeEnable;
copied to clipboard

(ANDROID ONLY) Get detailed breakdown of root detection methods for debugging

Map<String, dynamic> rootDetails = await SafeDevice.rootDetectionDetails;
copied to clipboard

Enhanced iOS Jailbreak Detection #

The plugin now includes enhanced jailbreak detection for iOS with comprehensive path checking. The custom detection method checks for:

Jailbreak Tool Paths #

  • Cydia and package managers (/Applications/Cydia.app, /private/var/lib/apt, etc.)
  • System binaries commonly found on jailbroken devices (/bin/bash, /usr/sbin/sshd, etc.)
  • MobileSubstrate files (/Library/MobileSubstrate/MobileSubstrate.dylib)
  • APT package manager files (/etc/apt, /var/lib/dpkg/status)
  • Launch daemons (/System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist)

Detection Methods #

  • Path Existence: Checks for files and directories commonly present on jailbroken devices
  • URL Scheme Detection: Tests if jailbreak-related URL schemes can be opened
  • Sandbox Violation: Attempts to write outside the app sandbox
  • Environment Variables: Checks for jailbreak-related environment variables
  • Symbolic Link Detection: Looks for suspicious symbolic links
  • Process Detection: Checks for running jailbreak-related processes

Usage Example #

// Basic jailbreak detection (uses both DTTJailbreakDetection and custom detection)
bool isJailbroken = await SafeDevice.isJailBroken;

// Custom detection only (comprehensive path checking)
bool isJailbrokenCustom = await SafeDevice.isJailBrokenCustom;

// Detailed breakdown of detection methods
Map<String, bool> details = await SafeDevice.jailbreakDetails;
// Returns:
// {
//   "hasPaths": false,
//   "canOpenSchemes": false,
//   "canViolateSandbox": false,
//   "hasEnvironmentVariables": false,
//   "hasSuspiciousSymlinks": false,
//   "hasJailbreakProcesses": false
// }
copied to clipboard

Note: #

Mock location detection

  • Android - Location permission is required to detect mock location. The check can be disabled at runtime via config.

DevelopmentMode #

  • -Development Options in emulator always is true for default

❗Since emulators are usually rooted, you might want to bypass these checks during development. Unless you're keen on constant false alarms ⏰ #

348
likes
130
points
121k
downloads

Publisher

unverified uploader

Weekly Downloads

2024.12.17 - 2025.11.11

This package helps to detect iOS Simulator, Android Emulator and Debug Mode. This package also detects MockLocation/Fake GPS location on Android Device. Also check device is real or not.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on safe_device

Packages that implement safe_device