flutter_root_detection_plus 0.0.1
flutter_root_detection_plus: ^0.0.1 copied to clipboard
Flutter Root Detection for Both Android and IOS which does not run the application on root or sudo.
example/lib/main.dart
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_root_detection_plus/flutter_root_detection_plus.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _isRooted = 'Unknown';
String _isInDevMode = 'Unknown';
String _isVirtualDevice = 'Unknown';
final _flutterRootDetectionPlusPlugin = FlutterRootDetectionPlus();
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
try {
_isRooted = (await _flutterRootDetectionPlusPlugin.getIsJailBroken())
.toString();
} on PlatformException {
_isRooted = 'Failed to get if Rooted or not.';
}
try {
_isInDevMode = (await _flutterRootDetectionPlusPlugin.getIsDevMode())
.toString();
} on PlatformException {
_isRooted = 'Failed to get if device is in dev mode or not.';
}
try {
_isVirtualDevice =
(await _flutterRootDetectionPlusPlugin.getIsVirtualDevice())
.toString();
} on PlatformException {
_isRooted = 'Failed to get if app is running in virtual device or not.';
}
if (!mounted) return;
setState(() {});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Root detection plus example')),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('is Device Rooted: $_isRooted'),
Text('is Device in Dev Mode: $_isInDevMode'),
Text('is Virtual Device: $_isVirtualDevice'),
],
),
),
),
);
}
}