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.
Package selection guidance compiled from public package information, community data, and project usage.
The safe_device package helps developers detect whether an app is running on a simulated environment such as the iOS Simulator, Android Emulator, or in debug mode. It also identifies fake GPS locations on Android devices and determines if the device is genuine. This enhances security by preventing unauthorized access from emulated or spoofed environments. The package is useful for applications requiring strong device integrity checks, especially in financial or sensitive data contexts.
Use cases
Securing apps against emulator usage
Detecting fake GPS locations
Preventing debug mode exploitation
Validating real device presence
Enhancing fraud detection
Protecting sensitive data access
Key features
Detects iOS Simulator
Identifies Android Emulator
Checks for Debug Mode
Detects MockLocation/Fake GPS
Verifies device authenticity
Lightweight and platform-agnostic
Suitable for
Security-focused applications
Financial or banking apps
Fraud prevention systems
Apps requiring device integrity
Developers prioritizing runtime safety
Mobile apps with high-security requirements
Considerations
Limited to Android and iOS platforms
Does not prevent all forms of spoofing
Relies on device-specific indicators
May trigger false positives on rooted devices
Requires proper permission handling on Android
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
safe_device (Null-Safety)
Flutter (Null-Safety) Jailbroken, root, emulator and mock location detection.
Getting Started
In your flutter project add the dependency:
dependencies:...safe_device:^1.4.1
Usage
Importing package
import'package:safe_device/safe_device.dart';
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';
voidmain() async {
SafeDevice.init(
SafeDeviceConfig(mockLocationCheckEnabled: false), // disables mock location check on Android
);
// ...rest of your app
}
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 = awaitSafeDevice.isJailBroken;
(iOS ONLY) Enhanced jailbreak detection with custom path checking
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
Detects a wide range of Android emulators including:
Android SDK Emulator, Genymotion
LDPlayer, MEmu, BlueStacks, MuMu Player (NetEase), Nox, Droid4X
Known Limitations
Root and jailbreak detection is a best-effort approach. A determined attacker using tools such as Magisk Hide or Zygisk can bypass detection. This plugin is intended as a security layer — not a guarantee.
Device-specific handling: Some manufacturers (Samsung, Xiaomi, Vivo) ship with system properties or Knox security components that can cause false positives. The plugin applies conservative multi-indicator checks for these brands to balance accuracy and reliability.
Notes
Mock location detection
Android — Location permission is required to detect mock location. The check can be disabled at runtime via config.
iOS — Mock location detection is based on jailbreak/emulator status.
Development Mode
Development Options in emulator is always true by default.
❗Since emulators are usually rooted, you might want to bypass these checks during development. Unless you're keen on constant false alarms ⏰