safe_device 1.1.1 copy "safe_device: ^1.1.1" to clipboard
safe_device: ^1.1.1 copied to clipboard

outdated

With the Flutter safe_device package, you can easily implement security steps such as Jailbroken, root, emulator and fake location detection.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:location_permissions/location_permissions.dart';
import 'package:safe_device/safe_device.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool isJailBroken = false;
  bool canMockLocation = false;
  bool isRealDevice = true;
  bool isOnExternalStorage = false;
  bool isSafeDevice = false;
  bool isDevelopmentModeEnable = false;
  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    await LocationPermissions().requestPermissions();
    if (!mounted) return;
    try {
      isJailBroken = await SafeDevice.isJailBroken;
      canMockLocation = await SafeDevice.canMockLocation;
      isRealDevice = await SafeDevice.isRealDevice;
      isOnExternalStorage = await SafeDevice.isOnExternalStorage;
      isSafeDevice = await SafeDevice.isSafeDevice;
      isDevelopmentModeEnable = await SafeDevice.isDevelopmentModeEnable;
    } catch (error) {
      print(error);
    }

    setState(() {
      isJailBroken = isJailBroken;
      canMockLocation = canMockLocation;
      isRealDevice = isRealDevice;
      isOnExternalStorage = isOnExternalStorage;
      isSafeDevice = isSafeDevice;
      isDevelopmentModeEnable = isDevelopmentModeEnable;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Device Safe check'),
        ),
        body: Center(
          child: Card(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text('isJailBroken():'),
                      SizedBox(
                        width: 8,
                      ),
                      Text(
                        '${isJailBroken ? "Yes" : "No"}',
                        style: TextStyle(fontWeight: FontWeight.w600),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text('canMockLocation():'),
                      SizedBox(
                        width: 8,
                      ),
                      Text(
                        '${canMockLocation ? "Yes" : "No"}',
                        style: TextStyle(fontWeight: FontWeight.w600),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text('isRealDevice():'),
                      SizedBox(
                        width: 8,
                      ),
                      Text(
                        '${isRealDevice ? "Yes" : "No"}',
                        style: TextStyle(fontWeight: FontWeight.w600),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text('isOnExternalStorage():'),
                      SizedBox(
                        width: 8,
                      ),
                      Text(
                        '${isOnExternalStorage ? "Yes" : "No"}',
                        style: TextStyle(fontWeight: FontWeight.w600),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text('isSafeDevice():'),
                      SizedBox(
                        width: 8,
                      ),
                      Text(
                        '${isSafeDevice ? "Yes" : "False"}',
                        style: TextStyle(fontWeight: FontWeight.w600),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text('isDevelopmentModeEnable():'),
                      SizedBox(
                        width: 8,
                      ),
                      Text(
                        '${isDevelopmentModeEnable ? "Yes" : "False"}',
                        style: TextStyle(fontWeight: FontWeight.w600),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
238
likes
0
pub points
97%
popularity

Publisher

unverified uploader

With the Flutter safe_device package, you can easily implement security steps such as Jailbroken, root, emulator and fake location detection.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, trust_location

More

Packages that depend on safe_device