Closed manvirrr closed 1 year ago
@manvirrr What platform are you using? do you have any more relevant logs? If not, please provide a reproducible example.
Hi Matan,
i am using Flutter 3.0.4 with Dart 2.17.5 on Macbook M1 pro and Macbook Pro 16 Intel variant. It's the same error on both the machines.
flutter: FlutterGooglePlacesSdk::call error: PlatformException(API_ERROR, The operation couldn’t be completed. An internal error occurred in the Places SDK library. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/ios-sdk/support)., null, null) [VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: PlatformException(API_ERROR, The operation couldn’t be completed. An internal error occurred in the Places SDK library. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/ios-sdk/support)., null, null)
I am able to get the list of Predictions using the package but when I pass the PlaceId to fetchPlace function, I get the above error.
So following is the base..
void initState() { // TODO: implement initState super.initState(); _googlePlaces = FlutterGooglePlacesSdk(key); }
Autocomplete
// final String request =
// "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${textEditingValue.text}&components=country:PL&key=${key}&sessiontoken=${sessionId}";
// final result = await client
// .get(Uri.parse(request), headers: {
// "referer": dotenv.env['HTTPREF']!,
// "origin": dotenv.env['HTTPREF']!
// });
// print("${sessionId} - ${result.body}");
// if (result.statusCode == 200) {
// return [result.body];
// }
return [];
//return jsonDecode(request)["predictions"];
},
fieldViewBuilder: (
BuildContext context,
TextEditingController mapSearch,
FocusNode mapFocusNode,
VoidCallback onFieldSubmit,
) {
return TextFormField(
controller: mapSearch,
onChanged: (value) {},
onTap: () => setState(() {
searchHasFocus = true;
}),
decoration: const InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.only(
left: 38, top: 0, bottom: 5),
),
focusNode: mapFocusNode,
textCapitalization:
TextCapitalization.sentences,
);
},
displayStringForOption: (place) =>
place.primaryText,
optionsMaxHeight: screenHeight,
onSelected: (option) async {
final selectedPlace =
await _googlePlaces.fetchPlace(
option.placeId,
);
print(selectedPlace);
selectedLocation = {
"lat":
selectedPlace.place!.latLng!.lat.toString(),
"lng":
selectedPlace.place!.latLng!.lng.toString(),
"address": selectedPlace.place!.address,
};
},
optionsViewBuilder: (BuildContext context,
AutocompleteOnSelected<AutocompletePrediction>
onSelected,
Iterable<AutocompletePrediction> places) {
return Align(
alignment: Alignment.topLeft,
child: Material(
child: Container(
width: screenWidth - 30 * 2 - 22.1 * 2,
decoration: const BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color(0x1A000000),
offset: Offset(0, 3),
blurRadius: 6,
),
],
),
child: Builder(builder: (BuildContext) {
List<Widget> children = [];
// final List<dynamic> placesList = jsonDecode(places.first)['predictions'];
print("Plaxes 0- ${places}");
places.forEach(
(place) {
children.add(Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.only(
top: 20,
left: 20,
right: 20,
bottom: 20),
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color:
Color(0xfff9f9f9),
width: 2,
style: BorderStyle
.solid))),
child: GestureDetector(
onTap: (() async {
onSelected(place);
}),
child: Text(place.fullText)),
));
},
);
// for (int i = 0; i < places.length; i++) {
// children.add(Container(
// alignment: Alignment.centerLeft,
// padding: const EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 20),
// decoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Color(0xfff9f9f9), width: 2, style: BorderStyle.solid))),
// child: Text(),
// ));
// }
return ListView(
children: children,
shrinkWrap: true,
padding:
const EdgeInsets.only(bottom: 50),
);
// return Column(
// children: children,
// );
}),
),
),
);
},
),
Hi... I think i found the issue... I was not passing placefieldds to fetchPlace. Passing fields solved the issue... Thanks....
@manvirrr great.
Keeping tihs issue open since the package should return a better error than what you are getting in this case.
I think it would be better to make fields a required parameter.
flutter_google_places_sdk_platform_interface has been updated to mark parameter as required ( 0.2.4+2 ). Will update dependencies over time.
I get the list of predictions successfully but when I try to fetch a place, I get an internal error.
Unhandled Exception: PlatformException(API_ERROR, The operation couldn’t be completed. An internal error occurred in the Places SDK library. If you believe this error represents a bug, please file a report using the instructions on our community and support page (https://developers.google.com/places/ios-sdk/support)., null, null)
Thanks