get events from current position
This commit is contained in:
@@ -11,6 +11,7 @@ import 'pages/ListItemMenu.dart';
|
||||
import 'classes/alert.dart';
|
||||
|
||||
import 'variable/globals.dart' as globals;
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MyApp());
|
||||
@@ -153,10 +154,49 @@ class _LoginDemoState extends State<LoginDemo> with ShowErrorDialog {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_checkLocationPermission();
|
||||
start();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> _checkLocationPermission() async {
|
||||
PermissionStatus status = await Permission.location.status;
|
||||
|
||||
if (status.isGranted) {
|
||||
print("Location permission granted");
|
||||
} else if (status.isDenied) {
|
||||
print("Location permission denied");
|
||||
_requestLocationPermission();
|
||||
} else if (status.isPermanentlyDenied) {
|
||||
print("Location permission permanently denied");
|
||||
openAppSettings();
|
||||
}
|
||||
}
|
||||
|
||||
// Request location permission
|
||||
Future<void> _requestLocationPermission() async {
|
||||
PermissionStatus status = await Permission.location.request();
|
||||
|
||||
if (status.isGranted) {
|
||||
print("Location permission granted");
|
||||
} else if (status.isDenied) {
|
||||
print("Location permission denied");
|
||||
} else if (status.isPermanentlyDenied) {
|
||||
print("Location permission permanently denied");
|
||||
openAppSettings();
|
||||
}
|
||||
}
|
||||
|
||||
// Open app settings to allow user to grant permission manually
|
||||
Future<void> _openAppSettings() async {
|
||||
bool opened = await openAppSettings();
|
||||
if (opened) {
|
||||
print("App settings opened");
|
||||
} else {
|
||||
print("Failed to open app settings");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
Reference in New Issue
Block a user