security_plus 2.0.0 copy "security_plus: ^2.0.0" to clipboard
security_plus: ^2.0.0 copied to clipboard

A new Flutter plugin to detect more than one security alert like root, jailbreak, emulator, development mode , and external storage run.

example/lib/main.dart

import 'dart:async';
import 'dart:developer';
import 'dart:io';

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

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isRooted = true,
      _isDev = false,
      _isExtStorage = false,
      _isEmulator = false;
  bool _isMockLocationEnabled = false;

  @override
  void initState() {
    super.initState();
    isRooted();
    isExtStorage();
    isEmulator();
    isDevelopment();
    isMockLocationEnabled();
  }

  Future<void> isRooted() async {
    try {
      bool result = Platform.isAndroid
          ? await SecurityPlus.isRooted
          : await SecurityPlus.isJailBroken;
      _isRooted = result;
    } catch (e) {
      log('\x1B[31m${"=====error======"}\x1B[0m');
    }

    setState(() {});
  }

  Future<void> isExtStorage() async {
    if (Platform.isAndroid) {
      try {
        bool result = await SecurityPlus.isOnExternalStorage;
        _isExtStorage = result;
      } catch (e) {
        log('\x1B[31m${"=====error======"}\x1B[0m');
      }
    }

    setState(() {});
  }

  Future<void> isEmulator() async {
    if (Platform.isAndroid) {
      try {
        bool result = await SecurityPlus.isEmulator;
        _isEmulator = result;
      } catch (e) {
        log('\x1B[31m${"=====error======"}\x1B[0m');
      }
    }

    setState(() {});
  }

  Future<void> isMockLocationEnabled() async {
    if (Platform.isAndroid) {
      try {
        bool result = await SecurityPlus.isMockLocationEnabled;
        _isMockLocationEnabled = result;
      } catch (e) {
        log('\x1B[31m${"=====error======"}\x1B[0m');
      }
    }

    setState(() {});
  }

  Future<void> isDevelopment() async {
    if (Platform.isAndroid) {
      try {
        bool result = await SecurityPlus.isDevelopmentModeEnable;
        _isDev = result;
      } catch (e) {
        log('\x1B[31m${"=====error======"}\x1B[0m');
      }
    }

    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Rooted || JailBroken'),
        ),
        body: SizedBox(
          width: MediaQuery.of(context).size.width,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              SizedBox(
                width: MediaQuery.of(context).size.width,
                height: 100,
                child: Center(
                  child: Platform.isAndroid
                      ? Text('Android is rooted : $_isRooted\n')
                      : Text('iOS is is jail broken : $_isRooted\n'),
                ),
              ),
              if (Platform.isAndroid)
                SizedBox(
                  width: MediaQuery.of(context).size.width,
                  height: 100,
                  child: Center(
                      child:
                          Text('Android is Emulator device : $_isEmulator\n')),
                ),
              if (Platform.isAndroid)
                SizedBox(
                  width: MediaQuery.of(context).size.width,
                  height: 100,
                  child: Center(
                      child: Text('Android is Development mode : $_isDev\n')),
                ),
              if (Platform.isAndroid)
                SizedBox(
                  width: MediaQuery.of(context).size.width,
                  height: 100,
                  child: Center(
                      child: Text(
                          'Android is on External Storage : $_isExtStorage\n')),
                ),
              if (Platform.isAndroid)
                SizedBox(
                  width: MediaQuery.of(context).size.width,
                  height: 100,
                  child: Center(
                    child: Text(
                        'Mock Location Enabled: $_isMockLocationEnabled\n'),
                  ),
                ),
            ],
          ),
        ),
      ),
    );
  }
}
15
likes
0
points
302
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin to detect more than one security alert like root, jailbreak, emulator, development mode , and external storage run.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on security_plus