Comments (6)
I think it would be better to make fields a required parameter.
from flutter_google_places_sdk.
@manvirrr What platform are you using? do you have any more relevant logs? If not, please provide a reproducible example.
from flutter_google_places_sdk.
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(
optionsBuilder: (textEditingValue) async {
if (textEditingValue.text.length > 2) {
final FindAutocompletePredictionsResponse
predictions = await _googlePlaces
.findAutocompletePredictions(
textEditingValue.text,
countries: ['PL'],
newSessionToken: false);
//print(predictions);
return predictions.predictions;
}
// 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,
// );
}),
),
),
);
},
),
from flutter_google_places_sdk.
Hi... I think i found the issue... I was not passing placefieldds to fetchPlace. Passing fields solved the issue... Thanks....
from flutter_google_places_sdk.
@manvirrr great.
Keeping tihs issue open since the package should return a better error than what you are getting in this case.
from flutter_google_places_sdk.
Related Issues (20)
- Web Errors/Exceptions cannot be caught when using parent plugin HOT 7
- Parse Issue (Xcode): Module 'flutter_google_places_sdk_ios' not found HOT 2
- Feature request: language option HOT 2
- [iOS] Viewport is null on iOS HOT 4
- Flutter Web: You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors. HOT 10
- [iOS] Google Places -> Add arm64 support? HOT 1
- Flutter Web | Places Autocomplete Error | Expected a value of type 'Object', but got one of type 'Null' HOT 4
- [IOS] locationBias and locationRestriction is not implemented
- Export flutter_google_places_sdk_platform_interface package HOT 1
- [Android] get warning 'toUpperCase(Locale): String' is deprecated
- [Web] Changing the locale of FlutterGooglePlacesSdk doesn't work HOT 6
- Issue null cannot be cast to non-null type kotlin.String HOT 3
- Feature Request: Add iOS Support HOT 1
- Calling fetchPlace using web_sdk when running in --release or --profile mode throws errors. HOT 3
- AutocompletionRequest is missing a few params HOT 2
- Accessing place photos (flutter web in chrome with flutter_google_places_sdk: ^0.3.0+1) HOT 2
- Crash on iOS HOT 4
- Add location constraints HOT 3
- Duplicate classes then java.lang.ExceptionInInitializerError HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_google_places_sdk.