detect_fake_location_plus 1.0.4+1 detect_fake_location_plus: ^1.0.4+1 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_plus/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('检测虚拟定位'),
onPressed: () async {
bool isFakeLocation =
await DetectFakeLocation().detectFakeLocation();
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('检测虚拟定位'),
content: Text(' 此用户${isFakeLocation ? '' : '不'}是虚拟定位'),
actions: <Widget>[
TextButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
),
),
);
}
}