-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added Prediction screen and changed firebase project (#58)
* feat: added Prediction screen and changed firebase project * fix: failing CI
- Loading branch information
1 parent
088f0ee
commit 4d1df6e
Showing
8 changed files
with
132 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,6 @@ app.*.symbols | |
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Credentials | ||
lib/credentials.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Model for Place. | ||
class Place { | ||
Place( | ||
this.placeId, | ||
this.address, | ||
this.lat, | ||
this.long, | ||
); | ||
|
||
final String placeId; | ||
final String address; | ||
final double lat; | ||
final double long; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'dart:async'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_google_places/flutter_google_places.dart'; | ||
import 'package:google_maps_webservice/places.dart'; | ||
import 'package:knowyourdonor/models/Place.dart'; | ||
|
||
// const kGoogleApiKey = API_KEY; | ||
GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: ""); | ||
|
||
class Location { | ||
Future<Place> predictionScreen(BuildContext context) async { | ||
Prediction p = await PlacesAutocomplete.show( | ||
context: context, | ||
apiKey: "", | ||
onError: onError, | ||
mode: Mode.fullscreen, | ||
language: "eng", | ||
components: [Component(Component.country, "ind")], | ||
); | ||
return displayPrediction(p); | ||
} | ||
|
||
Future<Place> displayPrediction(Prediction p) async { | ||
if (p != null) { | ||
PlacesDetailsResponse detail = | ||
await _places.getDetailsByPlaceId(p.placeId); | ||
|
||
var placeId = p.placeId; | ||
var lat = detail.result.geometry.location.lat; | ||
var long = detail.result.geometry.location.lng; | ||
|
||
var address = detail.result.formattedAddress; | ||
|
||
Place place = Place(placeId, address, lat, long); | ||
|
||
print("Lat " + lat.toString()); | ||
print("Long " + long.toString()); | ||
print(address); | ||
|
||
return place; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
void onError(PlacesAutocompleteResponse response) { | ||
print('${response.errorMessage}'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters