I am currently trying to give access to users to do something when users are in radius x meters from position that I have determined. So, what I mean is.. I declare a position with x latitude and y longitude.. and then if users position is 500 meters from position that I have declare, they can access something else... is there a way to do that? here is part of my code
Position _mine;
Future _searchMe() async {
if ((await Geolocator().isLocationServiceEnabled())) {
final Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
geolocator
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high)
.then((Position position) {
setState(() {
_mine = position;
});
print(_mine.latitude);
}).catchError((err) {
print(err);
});
} else {
print("ok");
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
content:
const Text('Make sure your GPS is on !'),
actions: <Widget>[
FlatButton(
child: Text('ok'),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop();
})
],
);
});
}
}