Skip to main content

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

Detect device integrity issues (root, jailbreak, emulator, VPN, mock location, debugger, screen recording) on Android and iOS for fintech security.

example/flutter_device_guard_example.dart

import 'package:flutter_device_guard/flutter_device_guard.dart';

/// Demonstrates the main features of the flutter_device_guard package.
Future<void> main() async {
  // ── 1. Initialise with custom configuration ──────────────────────────────

  DeviceGuard().initialize(
    config: DeviceGuardConfig(
      cacheExpiry: const Duration(minutes: 10),
      enableCaching: true,
      threatsToCheck: [
        ThreatType.emulator,
        ThreatType.rooted,
        ThreatType.jailbroken,
        ThreatType.vpnDetected,
        ThreatType.mockLocationEnabled,
        ThreatType.debuggerAttached,
        ThreatType.screenRecording,
      ],
      onThreatDetected: (threat) {
        print('⚠️  Threat detected: ${threat.type} — ${threat.description}');
      },
    ),
  );

  // ── 2. Single check ──────────────────────────────────────────────────────

  final isRooted = await DeviceGuard().checkThreat(ThreatType.rooted);
  print('Device rooted: $isRooted');

  // ── 3. Get detailed threat information ────────────────────────────────────

  final threat = await DeviceGuard().getThreatDetails(ThreatType.vpnDetected);
  if (threat != null) {
    print('VPN threat: ${threat.description} (${threat.severity})');
  } else {
    print('No VPN detected.');
  }

  // ── 4. Full integrity report ──────────────────────────────────────────────

  final report = await DeviceGuard().checkAllThreats();
  print('Device safe: ${report.isDeviceSafe}');
  print('Threats found: ${report.threatsCount}');
  for (final t in report.threats) {
    print('  - ${t.type}: ${t.description} [${t.severity}]');
  }

  // ── 5. Check specific threats only ────────────────────────────────────────

  final partialReport = await DeviceGuard().checkThreats([
    ThreatType.emulator,
    ThreatType.debuggerAttached,
  ]);
  print('Partial report safe: ${partialReport.isDeviceSafe}');

  // ── 6. Continuous monitoring (stream) ─────────────────────────────────────

  // Uncomment to run — this never terminates.
  // DeviceGuard()
  //     .monitorThreats(checkInterval: const Duration(seconds: 15))
  //     .listen((threat) {
  //   print('Monitor: ${threat.type} — ${threat.description}');
  // });

  // ── 7. Monitor a single threat ────────────────────────────────────────────

  // Uncomment to run — this never terminates.
  // DeviceGuard()
  //     .monitorThreat(ThreatType.screenRecording)
  //     .listen((detected) {
  //   print('Screen recording active: $detected');
  // });

  // ── 8. Reset cache ────────────────────────────────────────────────────────

  DeviceGuard().resetCache();
  print('Cache cleared.');
}
0
likes
130
points
42
downloads

Documentation

API reference

Publisher

verified publishervenx.site

Weekly Downloads

Detect device integrity issues (root, jailbreak, emulator, VPN, mock location, debugger, screen recording) on Android and iOS for fintech security.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_device_guard

Packages that implement flutter_device_guard