Reputation: 980
I am developing an application using google map and google places.
When I call PlacesAutocomplete.show()
, it gives the following error message. Null check operator used on a null value
pubspec.yaml
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
google_maps_flutter: ^2.0.5
flutter_polyline_points: ^1.0.0
location: ^4.1.1
flutter_google_places: ^0.3.0
Call
InkWell(
onTap: () async {
Prediction p = await PlacesAutocomplete.show(
context: context,
apiKey: GOOGLE_API_KEY,
);
}, child: Text("SHOW")
),
Thanks in advance.
Upvotes: 0
Views: 2953
Reputation: 180
You need to provide all the required and non null parameters of the function .show. Something like that:
Prediction p = await PlacesAutocomplete.show( offset: 0, radius: 1000, strictbounds: false, region: "us", language: "en", context: context, mode: Mode.overlay, apiKey: Env.googleapikey, sessionToken: sessionToken, components: [new Component(Component.country, "us")], types: ["(cities)"], hint: "Search City", startText: city == null || city == "" ? "" : city );
Upvotes: 4