permission check when trying to open tracking map
This commit is contained in:
@@ -28,4 +28,15 @@ class GeolocatorService {
|
||||
|
||||
return await Geolocator.getCurrentPosition();
|
||||
}
|
||||
|
||||
static Future<bool> alwaysPositionEnabled() async {
|
||||
LocationPermission permissionGiven = await Geolocator.checkPermission();
|
||||
bool locationEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
|
||||
if (permissionGiven == LocationPermission.always || !locationEnabled) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
import 'package:fforte/screens/addCam/services/geolocator_service.dart';
|
||||
import 'package:fforte/screens/helper/add_entries_dialog_helper.dart';
|
||||
import 'package:fforte/screens/helper/snack_bar_helper.dart';
|
||||
import 'package:fforte/services/notification_service.dart';
|
||||
@@ -59,6 +60,13 @@ class _TrackingState extends State<Tracking> {
|
||||
);
|
||||
|
||||
super.initState();
|
||||
|
||||
GeolocatorService.alwaysPositionEnabled().then((value) {
|
||||
if (!value && mounted) {
|
||||
Navigator.of(context).pop();
|
||||
SnackBarHelper.showSnackBarMessage(context, "${AppLocalizations.of(context)!.locationForbidden} ${AppLocalizations.of(context)!.oder} ${AppLocalizations.of(context)!.locationDisabled}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -108,6 +116,7 @@ class _TrackingState extends State<Tracking> {
|
||||
notificationText: "",
|
||||
)
|
||||
: null,
|
||||
|
||||
),
|
||||
).listen((Position? position) {
|
||||
if (position != null) {
|
||||
|
||||
Reference in New Issue
Block a user