Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ganti di action nya
- onTap: () {
- handlePressButton();
- },
- //function autocomplete
- Future<void> _handlePressButton() async {
- try {
- final center = await getUserLocation();
- // GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: kGoogleApiKey);
- Prediction p = await PlacesAutocomplete.show(
- context: context,
- strictbounds: center == null ? false : true,
- apiKey: kGoogleApiKey,
- onError: onError,
- mode: Mode.overlay,
- language: "id",
- location: center == null
- ? null
- : Location(center.latitude, center.longitude),
- radius: center == null ? null : 10000000);//ini tergantung sejauh mana pencariannya
- PlacesDetailsResponse place =
- await _places.getDetailsByPlaceId(p.placeId);
- // print("${center.latitude}, ${center.longitude}");
- // print(place.result.name);
- // setState(() {
- // startLocation = TextEditingController(text: place.result.name);
- // lat = TextEditingController(
- // text: place.result.geometry.location.lat.toString());
- // long = TextEditingController(
- // text: place.result.geometry.location.lng.toString());
- // myLat = TextEditingController(text: center.latitude.toString());
- // myLong = TextEditingController(text: center.longitude.toString());
- // });
- // showDetailPlace(p.placeId);
- } catch (e) {
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement