Skip to content

Commit 881e77d

Browse files
authored
Merge pull request #684 from ikicodedev/master
Fix error in readme example code
2 parents 4445a43 + 67683a6 commit 881e77d

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,22 @@ Future<Position> _determinePosition() async {
128128
129129
permission = await Geolocator.checkPermission();
130130
if (permission == LocationPermission.denied) {
131-
permission = await Geolocator.requestPermission();
132-
if (permission == LocationPermission.deniedForever) {
133-
// Permissions are denied forever, handle appropriately.
134-
return Future.error(
135-
'Location permissions are permanently denied, we cannot request permissions.');
136-
}
137-
131+
permission = await Geolocator.requestPermission();
138132
if (permission == LocationPermission.denied) {
139133
// Permissions are denied, next time you could try
140134
// requesting permissions again (this is also where
141135
// Android's shouldShowRequestPermissionRationale
142136
// returned true. According to Android guidelines
143137
// your App should show an explanatory UI now.
144-
return Future.error(
145-
'Location permissions are denied');
138+
return Future.error('Location permissions are denied');
146139
}
147140
}
141+
142+
if (permission == LocationPermission.deniedForever) {
143+
// Permissions are denied forever, handle appropriately.
144+
return Future.error(
145+
'Location permissions are permanently denied, we cannot request permissions.');
146+
}
148147
149148
// When we reach here, permissions are granted and we can
150149
// continue accessing the position of the device.

geolocator/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,22 @@ Future<Position> _determinePosition() async {
128128
129129
permission = await Geolocator.checkPermission();
130130
if (permission == LocationPermission.denied) {
131-
permission = await Geolocator.requestPermission();
132-
if (permission == LocationPermission.deniedForever) {
133-
// Permissions are denied forever, handle appropriately.
134-
return Future.error(
135-
'Location permissions are permanently denied, we cannot request permissions.');
136-
}
137-
131+
permission = await Geolocator.requestPermission();
138132
if (permission == LocationPermission.denied) {
139133
// Permissions are denied, next time you could try
140134
// requesting permissions again (this is also where
141135
// Android's shouldShowRequestPermissionRationale
142136
// returned true. According to Android guidelines
143137
// your App should show an explanatory UI now.
144-
return Future.error(
145-
'Location permissions are denied');
138+
return Future.error('Location permissions are denied');
146139
}
147140
}
141+
142+
if (permission == LocationPermission.deniedForever) {
143+
// Permissions are denied forever, handle appropriately.
144+
return Future.error(
145+
'Location permissions are permanently denied, we cannot request permissions.');
146+
}
148147
149148
// When we reach here, permissions are granted and we can
150149
// continue accessing the position of the device.

0 commit comments

Comments
 (0)