Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## [0.2.1] - 2021-07-01
- Added ability to pass custom headers in requests.

## [0.2.0] - 2021-03-15

- Add null-safety
Expand Down
8 changes: 4 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.7.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -115,7 +115,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.4.0"
path:
dependency: transitive
description:
Expand All @@ -141,7 +141,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -176,7 +176,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.4.0"
typed_data:
dependency: transitive
description:
Expand Down
10 changes: 8 additions & 2 deletions lib/google_geocoding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ class GoogleGeocoding {
final String apiKEY;
late Geocoding geocoding;

GoogleGeocoding(this.apiKEY) {
this.geocoding = Geocoding(apiKEY);
/// Optional headers to pass on each request
final Map<String, String> headers;

GoogleGeocoding(
this.apiKEY, {
this.headers = const {},
}) {
this.geocoding = Geocoding(apiKEY, headers);
}
}
7 changes: 4 additions & 3 deletions lib/src/geocoding/geocoding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class Geocoding {
final _authority = 'maps.googleapis.com';
final _unencodedPath = 'maps/api/geocode/json';
final String apiKEY;
final Map<String, String> headers;

Geocoding(this.apiKEY);
Geocoding(this.apiKEY, this.headers);

/// Geocoding is the process of converting addresses (like a street address) into geographic coordinates (like latitude and longitude),
/// which you can use to place markers on a map, or position the map.
Expand Down Expand Up @@ -56,7 +57,7 @@ class Geocoding {
region,
);
var uri = Uri.https(_authority, _unencodedPath, queryParameters);
var response = await NetworkUtility.fetchUrl(uri);
var response = await NetworkUtility.fetchUrl(uri, headers: headers);
if (response != null) {
return GeocodingResponse.parseGeocodingResponse(response);
}
Expand Down Expand Up @@ -104,7 +105,7 @@ class Geocoding {
locationType,
);
var uri = Uri.https(_authority, _unencodedPath, queryParameters);
var response = await NetworkUtility.fetchUrl(uri);
var response = await NetworkUtility.fetchUrl(uri, headers: headers);
if (response != null) {
return GeocodingResponse.parseGeocodingResponse(response);
}
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.7.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -87,7 +87,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.4.0"
path:
dependency: transitive
description:
Expand All @@ -113,7 +113,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -148,7 +148,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.4.0"
typed_data:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: google_geocoding
description: A new Flutter package for handle google geocoding api that geocoding and reverse geocoding requests are available
version: 0.2.0
version: 0.2.1
homepage: https://github.com/bazrafkan/google_geocoding

environment:
Expand Down