overlay_attack_detector 0.0.1
overlay_attack_detector: ^0.0.1 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;
@override
void initState() {
super.initState();
checkOverlay();
}
Future<void> checkOverlay() async {
final result = await OverlayAttackDetector.isOverlayEnabled();
if (!mounted) return;
setState(() {
_overlayEnabled = result;
});
}
@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",
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
OverlayAttackDetector.openOverlaySettings();
},
child: const Text("Open Overlay Settings"),
)
],
),
),
),
);
}
}