detect_fake_location 0.0.2
detect_fake_location: ^0.0.2 copied to clipboard
A Flutter plugin for detecting if location is being simulated or faked
import 'package:flutter/material.dart';
import 'package:detect_fake_location/detect_fake_location.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My App',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My App'),
),
body: Center(
child: ElevatedButton(
child: Text('Detect Fake Location'),
onPressed: () async {
bool isFakeLocation =
await DetectFakeLocation().detectFakeLocation();
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Fake Location Detected'),
content: Text(
'The user is${isFakeLocation ? '' : ' not'} using a fake location.'),
actions: <Widget>[
TextButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
),
),
);
}
}