Texto original em inglês. Visite o GitHub para a versão atual.
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 ⏰