overlay_attack_detector 0.0.9 copy "overlay_attack_detector: ^0.0.9" to clipboard
overlay_attack_detector: ^0.0.9 copied to clipboard

Flutter plugin to detect overlay attacks and obscured touches for secure payment flows on Android.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  bool overlayEnabled = false;
  bool overlayDetected = false;

  @override
  void initState() {
    super.initState();
    checkOverlayPermission();
    listenOverlay();
  }

  Future<void> checkOverlayPermission() async {
    final result = await OverlayAttackDetector.isOverlayEnabled();

    setState(() {
      overlayEnabled = result;
    });
  }

  void listenOverlay() {
    OverlayAttackDetector.overlayAttackStream.listen((detected) {
      setState(() {
        overlayDetected = detected;
      });

      if (detected) {
        showDialog(
          context: context,
          builder: (_) => const AlertDialog(
            title: Text("Security Warning"),
            content: Text("Overlay detected. Please disable overlay apps."),
          ),
        );
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text("Overlay Attack Detector"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                overlayEnabled
                    ? "Overlay Permission Enabled"
                    : "Overlay Permission Disabled",
                style: const TextStyle(fontSize: 18),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () {
                  OverlayAttackDetector.openOverlaySettings();
                },
                child: const Text("Open Overlay Settings"),
              ),
              const SizedBox(height: 40),
              Text(
                overlayDetected
                    ? "⚠ Overlay Attack Detected"
                    : "No Overlay Detected",
                style: TextStyle(
                  fontSize: 22,
                  color: overlayDetected ? Colors.red : Colors.green,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
140
points
139
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter plugin to detect overlay attacks and obscured touches for secure payment flows on Android.

Repository (GitHub)
View/report issues

Topics

#flutter-plugin #android-security #overlay-detection #tapjacking

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on overlay_attack_detector

Packages that implement overlay_attack_detector