root plugin
a flutter plugin to check android device root status and run shell commands in android(only).
this plugin is based on topjohnwu libsu and stericson root tools.
usage
to use this plugin, add root
as a dependency in your pubspec.yaml file.
root: ^2.0.1
import it
import 'package:root/root.dart';
declare a async method to check root status
bool _status = false;
future<void> checkroot() async {
bool result = await root.isrooted();
setstate(() {
_status = result;
});
}
later you can use _status in your code to let app know the root status.
declare a async method to run shell commands
use this function only for short period of processes, don’t use for long processes else app may crash
string _result;
future<void> setcommand() async {
string res = await root.exec(cmd: "cat /proc/version");
setstate(() {
_result = res;
});
}
later you can use the _result in your code to let know the output of the given shell command.
Comments are closed.