root_jailbreak_guard 1.0.0 copy "root_jailbreak_guard: ^1.0.0" to clipboard
root_jailbreak_guard: ^1.0.0 copied to clipboard

Flutter jailbreak and root detection plugin with AGP 8 support, enhanced security checks, and active maintenance. Forked from flutter_jailbreak_detection.

example/lib/main.dart

import 'dart:developer' as developer;
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:root_jailbreak_guard/root_jailbreak_guard.dart';

void main() {
  runApp(const RootJailbreakGuardExampleApp());
}

class RootJailbreakGuardExampleApp extends StatelessWidget {
  const RootJailbreakGuardExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Root Jailbreak Guard',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.teal),
        useMaterial3: true,
      ),
      home: const VerificationScreen(),
    );
  }
}

class VerificationScreen extends StatefulWidget {
  const VerificationScreen({super.key});

  @override
  State<VerificationScreen> createState() => _VerificationScreenState();
}

class _VerificationScreenState extends State<VerificationScreen> {
  bool? _jailbroken;
  bool? _developerMode;
  String? _error;
  bool _loading = true;

  @override
  void initState() {
    super.initState();
    _runChecks();
  }

  Future<void> _runChecks() async {
    setState(() {
      _loading = true;
      _error = null;
    });

    try {
      final jailbroken = await RootJailbreakGuard.jailbroken;
      final developerMode = await RootJailbreakGuard.developerMode;

      developer.log(
        'Platform: ${Platform.operatingSystem} | '
        'jailbroken=$jailbroken | developerMode=$developerMode',
        name: 'root_jailbreak_guard.verify',
      );
      // ignore: avoid_print
      print(
        '[root_jailbreak_guard.verify] platform=${Platform.operatingSystem} '
        'jailbroken=$jailbroken developerMode=$developerMode',
      );

      if (!mounted) return;
      setState(() {
        _jailbroken = jailbroken;
        _developerMode = developerMode;
        _loading = false;
      });
    } catch (error, stackTrace) {
      developer.log(
        'Check failed',
        name: 'root_jailbreak_guard.verify',
        error: error,
        stackTrace: stackTrace,
      );
      if (!mounted) return;
      setState(() {
        _error = error.toString();
        _loading = false;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Root Jailbreak Guard'),
        actions: [
          IconButton(
            onPressed: _loading ? null : _runChecks,
            icon: const Icon(Icons.refresh),
          ),
        ],
      ),
      body: Padding(
        padding: const EdgeInsets.all(24),
        child: _loading
            ? const Center(child: CircularProgressIndicator())
            : _error != null
                ? Text('Error: $_error', style: const TextStyle(color: Colors.red))
                : Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text('Platform: ${Platform.operatingSystem}'),
                      const SizedBox(height: 16),
                      _ResultTile(
                        label: 'jailbroken / rooted',
                        value: _jailbroken!,
                        passWhenFalse: true,
                      ),
                      const SizedBox(height: 12),
                      _ResultTile(
                        label: 'developer mode',
                        value: _developerMode!,
                        passWhenFalse: Platform.isAndroid,
                      ),
                      const SizedBox(height: 24),
                      const Text(
                        'Expected on clean simulators/emulators:\n'
                        '• jailbroken = false\n'
                        '• developer mode = true on iOS simulator, false on Android emulator',
                      ),
                    ],
                  ),
      ),
    );
  }
}

class _ResultTile extends StatelessWidget {
  const _ResultTile({
    required this.label,
    required this.value,
    required this.passWhenFalse,
  });

  final String label;
  final bool value;
  final bool passWhenFalse;

  @override
  Widget build(BuildContext context) {
    final bool ok = passWhenFalse ? !value : value;
    return ListTile(
      contentPadding: EdgeInsets.zero,
      leading: Icon(
        ok ? Icons.check_circle : Icons.info,
        color: ok ? Colors.green : Colors.orange,
      ),
      title: Text(label),
      subtitle: Text('Result: $value'),
    );
  }
}
0
likes
150
points
64
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter jailbreak and root detection plugin with AGP 8 support, enhanced security checks, and active maintenance. Forked from flutter_jailbreak_detection.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on root_jailbreak_guard

Packages that implement root_jailbreak_guard