Skip to content

Commit 7e63a56

Browse files
author
Lukasz
committed
Update readme and description.
1 parent c600aec commit 7e63a56

File tree

2 files changed

+42
-51
lines changed

2 files changed

+42
-51
lines changed

README.md

Lines changed: 41 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,33 @@
22

33
[![pub package](https://img.shields.io/pub/v/geolocation.svg)](https://pub.dartlang.org/packages/geolocation)
44

5-
Flutter [geolocation plugin](https://pub.dartlang.org/packages/geolocation/) for Android API 16+ and iOS 9+.
5+
Flutter [geolocation plugin](https://pub.dartlang.org/packages/geolocation/) for Android API 16+ and iOS 9+.
66

77
Features:
88

9-
* Manual and automatic location permission management
10-
* Current one-shot location
11-
* Continuous location updates with foreground and background options
9+
- Manual and automatic location permission management
10+
- Current one-shot location
11+
- Continuous location updates with foreground and background options
1212

1313
The plugin is under active development and the following features are planned soon:
1414

15-
* Geocode
16-
* Geofences
17-
* Place suggestions
18-
* Activity recognition
19-
* Exposition of iOS/Android specific APIs (like significant location updates on iOS)
20-
21-
22-
Android | iOS
23-
:---: | :---:
24-
![](https://github.com/loup-v/geolocation/blob/master/doc/android_screenshot.jpg?raw=true) | ![](https://github.com/loup-v/geolocation/blob/master/doc/ios_screenshot.jpg?raw=true)
15+
- Geocode
16+
- Geofences
17+
- Place suggestions
18+
- Activity recognition
19+
- Exposition of iOS/Android specific APIs (like significant location updates on iOS)
2520

21+
| Android | iOS |
22+
| :----------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------: |
23+
| ![](https://github.com/loup-v/geolocation/blob/master/doc/android_screenshot.jpg?raw=true) | ![](https://github.com/loup-v/geolocation/blob/master/doc/ios_screenshot.jpg?raw=true) |
2624

2725
## Installation
2826

2927
Add geolocation to your pubspec.yaml:
3028

3129
```yaml
3230
dependencies:
33-
geolocation:
34-
git:
35-
url: https://github.com/loup-v/geolocation
31+
geolocation: ^1.0.0
3632
```
3733
3834
## Import
@@ -44,19 +40,20 @@ import 'package:geolocation/geolocation.dart';
4440
```
4541

4642
**Note:** There is a known issue for integrating swift written plugin into Flutter project created with Objective-C template.
47-
See issue [Flutter#16049](https://github.com/flutter/flutter/issues/16049) for help on integration.
48-
43+
See issue [Flutter#16049](https://github.com/flutter/flutter/issues/16049) for help on integration.
4944

5045
### AndroidX Requirement
46+
5147
You may need to updated your '/android/gradle.properties' to include use of AndroidX.
48+
5249
```
5350
android.useAndroidX=true
5451
android.enableJetifier=true
5552
```
5653

5754
### Permission
5855

59-
Android and iOS require to declare the location permission in a configuration file.
56+
Android and iOS require to declare the location permission in a configuration file.
6057

6158
#### For iOS
6259

@@ -74,15 +71,14 @@ You need to declare the description for the desired permission in `ios/Runner/In
7471
<string>Reason why app needs location</string>
7572
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
7673
<string>Reason why app needs location</string>
77-
74+
7875
<!-- additionally for iOS 9/10, if you need always permission -->
7976
<key>NSLocationAlwaysUsageDescription</key>
8077
<string>Reason why app needs location</string>
8178
...
8279
</dict>
8380
```
8481

85-
8682
#### For Android
8783

8884
There are two kinds of location permission in Android: "coarse" and "fine".
@@ -96,10 +92,9 @@ You need to declare one of the two permissions in `android/app/src/main/AndroidM
9692
<!-- or -->
9793
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
9894
</manifest>
99-
```
100-
101-
Note that `ACCESS_FINE_LOCATION` permission includes `ACCESS_COARSE_LOCATION`.
95+
```
10296

97+
Note that `ACCESS_FINE_LOCATION` permission includes `ACCESS_COARSE_LOCATION`.
10398

10499
## API
105100

@@ -119,13 +114,13 @@ if(result.isSuccessful) {
119114
} else {
120115
// location service is not enabled, restricted, or location permission is denied
121116
}
122-
```
117+
```
123118

124119
### Request location permission
125120

126121
On Android (api 23+) and iOS, geolocation needs to request permission at runtime.
127122

128-
_Note: You are not required to request permission manually.
123+
_Note: You are not required to request permission manually.
129124
Geolocation plugin will request permission automatically if it's needed, when you make a location request._
130125

131126
API documentation: https://pub.dartlang.org/documentation/geolocation/0.2.1/geolocation/Geolocation/requestLocationPermission.html
@@ -140,22 +135,20 @@ if(result.isSuccessful) {
140135
// location permission is granted (or was already granted before making the request)
141136
} else {
142137
// location permission is not granted
143-
// user might have denied, but it's also possible that location service is not enabled, restricted, and user never saw the permission request dialog
138+
// user might have denied, but it's also possible that location service is not enabled, restricted, and user never saw the permission request dialog
144139
}
145-
```
146-
140+
```
147141

148142
### Get the current one-shot location
149143

150144
Geolocation offers three methods:
151145

152-
* Last known location (best on Android):
153-
https://pub.dartlang.org/documentation/geolocation/0.2.1/geolocation/Geolocation/lastKnownLocation.html
154-
* Single location update (best on iOS):
155-
https://pub.dartlang.org/documentation/geolocation/0.2.1/geolocation/Geolocation/singleLocationUpdate.html
156-
* Current location (best of both worlds, tries to retrieve last known location on Android, otherwise requests a single location update):
157-
https://pub.dartlang.org/documentation/geolocation/0.2.1/geolocation/Geolocation/currentLocation.html
158-
146+
- Last known location (best on Android):
147+
https://pub.dartlang.org/documentation/geolocation/0.2.1/geolocation/Geolocation/lastKnownLocation.html
148+
- Single location update (best on iOS):
149+
https://pub.dartlang.org/documentation/geolocation/0.2.1/geolocation/Geolocation/singleLocationUpdate.html
150+
- Current location (best of both worlds, tries to retrieve last known location on Android, otherwise requests a single location update):
151+
https://pub.dartlang.org/documentation/geolocation/0.2.1/geolocation/Geolocation/currentLocation.html
159152

160153
```dart
161154
// best option for most cases
@@ -175,7 +168,6 @@ StreamSubscription<LocationResult> subscription = Geolocation.currentLocation(ac
175168
LocationResult result = await Geolocation.lastKnownLocation();
176169
```
177170

178-
179171
### Continuous location updates
180172

181173
API documentation: https://pub.dartlang.org/documentation/geolocation/0.2.1/geolocation/Geolocation/locationUpdates.html
@@ -184,7 +176,7 @@ API documentation: https://pub.dartlang.org/documentation/geolocation/0.2.1/geol
184176
StreamSubscription<LocationResult> subscription = Geolocation.locationUpdates(
185177
accuracy: LocationAccuracy.best,
186178
displacementFilter: 10.0, // in meters
187-
inBackground: true, // by default, location updates will pause when app is inactive (in background). Set to `true` to continue updates in background.
179+
inBackground: true, // by default, location updates will pause when app is inactive (in background). Set to `true` to continue updates in background.
188180
)
189181
.listen((result) {
190182
if(result.isSuccessful) {
@@ -197,7 +189,6 @@ StreamSubscription<LocationResult> subscription = Geolocation.locationUpdates(
197189
subscription.cancel();
198190
```
199191

200-
201192
### Handle location result
202193

203194
Location request return either a `LocationResult` future or a stream of `LocationResult`.
@@ -208,7 +199,7 @@ API documentation: https://pub.dartlang.org/documentation/geolocation/0.2.1/geol
208199
LocationResult result = await Geolocation.lastKnownLocation();
209200
210201
if (result.isSuccessful) {
211-
// location request successful, location is guaranteed to not be null
202+
// location request successful, location is guaranteed to not be null
212203
double lat = result.location.latitude;
213204
double lng = result.location.longitude;
214205
} else {
@@ -221,7 +212,7 @@ if (result.isSuccessful) {
221212
break;
222213
case GeolocationResultErrorType.serviceDisabled:
223214
// location services disabled on device
224-
// might be that GPS is turned off, or parental control (android)
215+
// might be that GPS is turned off, or parental control (android)
225216
break;
226217
case GeolocationResultErrorType.permissionDenied:
227218
// user denied location permission request
@@ -242,21 +233,21 @@ if (result.isSuccessful) {
242233
break;
243234
}
244235
}
245-
```
246-
236+
```
247237

248238
## Authors
249239

250240
Geolocation plugin is developed by Loup, a mobile development studio based in Montreal and Paris.
251241
You can contact us at <[email protected]>
252242

253243
## Contributers
254-
* lukaspili
255-
* mit-mit
256-
* shehabic-work
257-
* Abgaryan
258-
* shehabic
259-
* alfanhui
244+
245+
- lukaspili
246+
- mit-mit
247+
- shehabic-work
248+
- Abgaryan
249+
- shehabic
250+
- alfanhui
260251

261252
## License
262253

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: geolocation
2-
description: Geolocation plugin for iOS and Android.
2+
description: Location plugin for iOS and Android.
33
version: 1.0.0
44
homepage: https://github.com/loup-v/geolocation/
55

0 commit comments

Comments
 (0)