DEV Community

Ahmad Darwish
Ahmad Darwish

Posted on

Detect Root And Jailbreak In Flutter App

You can detect root access on Android devices by checking for the presence of certain files or binaries that are typically only accessible with root privileges, while detecting jailbreak on iOS devices involves checking for the presence of certain files or system configurations that are typically modified during the jailbreaking process. One way to perform these checks is by using the flutter_device_info package.


1- Add the flutter_device_info package to your project by adding it to your pubspec.yaml file and running flutter pub get.

2- Import the package in your code:

import 'package:flutter_device_info/flutter_device_info.dart';

Enter fullscreen mode Exit fullscreen mode

3- Create an instance of the FlutterDeviceInfo class:

FlutterDeviceInfo flutterDeviceInfo = FlutterDeviceInfo();
Enter fullscreen mode Exit fullscreen mode

.

To determine whether a device is rooted, you can use the isRooted method:

bool isDeviceRooted = await flutterDeviceInfo.isRooted;
Enter fullscreen mode Exit fullscreen mode

The isRooted method returns a boolean value indicating whether the device is rooted. If the device is rooted, the method will return true; otherwise, it will return false.

.

For iOS devices, you can check if it's jailbroken by calling the isJailBroken method:

bool isDeviceJailbroken = await flutterDeviceInfo.isJailBroken;
Enter fullscreen mode Exit fullscreen mode

The isJailBroken method returns a boolean value indicating whether the device is jailbroken. If the device is jailbroken, the method will return true; otherwise, it will return false.


It's important to note that detecting jailbreak on iOS devices or root access on other devices is not a foolproof method of determining whether a device has been modified, as there are ways to hide these modifications from detection. Furthermore, detecting such modifications may not be necessary or appropriate for all apps, and may potentially violate platform policies or user privacy. Therefore, before attempting to detect jailbreak or root access, it's important to carefully consider the potential risks and benefits.

Top comments (0)