redmi update
This commit is contained in:
@@ -39,44 +39,10 @@ class MyHomePage extends StatefulWidget {
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
Future<Position> _determinePosition() async {
|
||||
bool serviceEnabled;
|
||||
LocationPermission permission;
|
||||
|
||||
// Check if location services are enabled
|
||||
serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
if (!serviceEnabled) {
|
||||
// If location services are disabled, show an error message or request the user to enable them
|
||||
throw Exception('Location services are disabled.');
|
||||
}
|
||||
// Check location permission
|
||||
permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
// If location permission is denied, request it
|
||||
permission = await Geolocator.requestPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
// If location permission is still denied, show an error message or redirect the user to the app settings
|
||||
throw Exception('Location permissions are denied');
|
||||
}
|
||||
}
|
||||
|
||||
// Check if location permission is permanently denied
|
||||
if (permission == LocationPermission.deniedForever) {
|
||||
// Show an error message or redirect the user to the app settings to enable location permissions
|
||||
throw Exception('Location permissions are permanently denied, we cannot request permissions.');
|
||||
}
|
||||
|
||||
// Get the current position
|
||||
return await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy: LocationAccuracy.best,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
_determinePosition();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -326,7 +326,7 @@ packages:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.0.0"
|
||||
version: "0.0.2"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -416,7 +416,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.1.7"
|
||||
permission_handler:
|
||||
dependency: "direct dev"
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: permission_handler
|
||||
sha256: "37fcc3c3182ac0bf8856f3e973e11c7bef5556d69f1a0d8fb908f51019c2912d"
|
||||
|
||||
@@ -35,6 +35,7 @@ dependencies:
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.2
|
||||
permission_handler:
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
@@ -46,7 +47,6 @@ dev_dependencies:
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^2.0.0
|
||||
permission_handler:
|
||||
map_camera_flutter:
|
||||
path: ../
|
||||
|
||||
|
||||
Reference in New Issue
Block a user