A Flutter plugin for rooted Android devices. It can:
- ask for root and tell you whether it was granted, denied, or not available,
- check for root without a prompt, looking for
su, Magisk, KernelSU, APatch, Frida, Xposed and more, - run shell commands as root, one at a time, in a long-lived session, or streamed line by line.
The plugin has no native dependencies. It is Android only; on other platforms every call answers safely (see Other platforms).
- Flutter 3.10+ (Dart 3)
- Android
minSdk21 or higher
flutter pub add root_accessimport 'package:root_access/root_access.dart';final RootAccessStatus status = await RootAccess.requestRoot();
switch (status) {
case RootAccessStatus.granted:
// Root is available.
break;
case RootAccessStatus.denied:
// su exists, but the user or the root manager said no.
break;
case RootAccessStatus.notRooted:
// No su on this device.
break;
case RootAccessStatus.timedOut:
// Nobody answered the superuser prompt (30 seconds by default).
break;
case RootAccessStatus.unsupported:
// Not Android.
break;
}requestRoot shows the root manager's prompt unless the app was already allowed or denied.
RootAccess.requestRootAccess (a bool) still works but is deprecated.
RootAccess.isRooted() looks for signs of root without running su, so the user never sees a superuser prompt.
It reads files, system properties and the app's own /proc entries, and returns a RootReport.
final RootReport report = await RootAccess.isRooted();
if (report.isRooted) {
print('su binaries: ${report.suBinaries}');
print('root apps: ${report.rootManagerApps}');
print('root mounts: ${report.rootMounts}');
}
if (report.isHooked) {
print('hooking frameworks: ${report.hookFrameworks}');
}| Group | Fields | Counted by |
|---|---|---|
| Strong signals | suBinaries, rootManagerApps (Magisk, KernelSU, APatch, SuperSU and others), rootMounts (Magisk/KernelSU/APatch mounts), systemWritable |
isRooted |
| Injected code | hookFrameworks (Frida, Xposed, LSPosed, Zygisk, Riru, Substrate) |
isHooked |
| Weak signals | testKeys, debuggable, insecure, bootloaderUnlocked, selinuxPermissive |
hasAnySignal |
| Context | emulator |
none |
Weak signals are also common on unrooted custom ROMs, development builds and emulators, so they don't make isRooted true.
Frida can be injected into a repackaged app without root, so hooking is reported separately.
Root can be hidden from all of these checks (for example with Magisk's DenyList, Shamiko or a randomized Magisk package name), so a clean report means "no root found", not proof that the device is unrooted. If you need a strong guarantee, use the Play Integrity API and verify its verdict on your server.
The plugin declares the root manager apps it looks for in a <queries> block, so Android 11+ package visibility
doesn't hide them. Your app needs no extra permission.
Every command is passed to the root shell as-is, so pipes, && and redirects work.
Never build a command from untrusted input.
final RootCommandResult result = await RootAccess.runAsRoot(
'ls /data/data',
timeout: const Duration(seconds: 10), // optional
);
if (result.success) {
print(result.stdout);
} else {
print('Failed (${result.exitCode}): ${result.stderr}');
}- If root access is denied,
suexits with a non-zero exit code and the command does not run. - If
suis missing (the device is not rooted), aPlatformExceptionwith codeROOT_UNAVAILABLEis thrown. - If the command takes longer than
timeout, the root shell is killed and aPlatformExceptionwith codeTIMEOUTis thrown. - At most
maxOutputBytes(1 MiB by default) of stdout and of stderr are kept.result.truncatedtells you when output was cut; passmaxOutputBytes: 0to keep everything.
Each runAsRoot call starts a new su. A RootSession keeps one root shell open, so the prompt appears once,
commands start faster, and state such as the working directory carries over.
final RootSession session = await RootAccess.openSession();
try {
await session.run('cd /data/local/tmp');
final RootCommandResult files = await session.run('ls -la');
print(files.stdout);
} finally {
await session.close();
}openSession throws a PlatformException with code ROOT_DENIED, ROOT_UNAVAILABLE or TIMEOUT when it can't get a
root shell. Commands run one at a time with stdin set to /dev/null. A timeout, or a command that ends the shell
(such as exit), closes the session; check session.isClosed.
final RootProcess process = await RootAccess.startAsRoot('logcat -d');
process.stdout.listen((String line) => print(line));
process.stderr.listen((String line) => print('ERR $line'));
final int exitCode = await process.exitCode;Lines arrive as the command prints them. Call process.kill() to stop it.
PlatformException.code |
Meaning |
|---|---|
ROOT_UNAVAILABLE |
su could not be started (device not rooted), or this isn't Android. |
ROOT_DENIED |
openSession only: the shell did not get root. |
TIMEOUT |
The command or prompt took longer than the timeout. |
SESSION_CLOSED |
The RootSession was closed. |
The plugin only has Android code. Elsewhere, no native code is called:
requestRoot returns RootAccessStatus.unsupported, isRooted returns a report with platformSupported == false
(no checks ran, which does not mean the device is clean), and the command APIs throw ROOT_UNAVAILABLE.
flutter testruns the Dart tests.- The Android code has JVM unit tests: build the example once (
cd example && flutter build apk --debug), then runcd example/android && ./gradlew :root_access:testDebugUnitTest. cd example && flutter test integration_testruns the plugin on a connected device or emulator.
See the example app for a complete sample.
Earlier versions were based on RootTools by Stericson.
Since 2.0.0 the plugin ships its own small su runner.
Please file issues to send feedback or report a bug. Thank you!