overlay_attack_detector 0.0.3 copy "overlay_attack_detector: ^0.0.3" to clipboard
overlay_attack_detector: ^0.0.3 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();
    checkOverlay();
    listenOverlay();
  }

  Future<void> checkOverlay() async {
    final result = await OverlayAttackDetector.isOverlayEnabled();
    if (!mounted) return;
    setState(() => _overlayEnabled = result);
  }

  void listenOverlay() {
    OverlayAttackDetector.overlayAttackStream.listen((detected) {
      if (!mounted) return;
      setState(() => _overlayDetected = detected);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Overlay Attack Detector Example')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                _overlayEnabled
                    ? "Overlay permission enabled"
                    : "Overlay permission disabled",
                style: const TextStyle(fontSize: 16),
              ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () => OverlayAttackDetector.openOverlaySettings(),
                child: const Text("Open Overlay Settings"),
              ),
              const SizedBox(height: 40),
              Text(
                _overlayDetected
                    ? "⚠️ Overlay detected! Possible attack!"
                    : "No overlay detected",
                style: TextStyle(
                  fontSize: 18,
                  fontWeight: FontWeight.bold,
                  color: _overlayDetected ? Colors.red : Colors.green,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
0
points
139
downloads

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