Skip to content

Issue with Force unwrap of getPlaceDetailWithLatLng #81

@nikekannan

Description

@nikekannan

In this function, there is an exception "Null Check operator is use on a null value". It will be better if written like this

if (widget.getPlaceDetailWithLatLng != null) {
        widget.getPlaceDetailWithLatLng!(prediction);
}

`Future getPlaceDetailsFromPlaceId(Prediction prediction) async {
//String key = GlobalConfiguration().getString('google_maps_key');

var url =
    "https://maps.googleapis.com/maps/api/place/details/json?placeid=${prediction.placeId}&key=${widget.googleAPIKey}";
debugPrint("urll 4 Selected Place : $url");
try {
  Response response = await _dio.get(
    url,
  );

  PlaceDetails placeDetails = PlaceDetails.fromJson(response.data);

  prediction.lat = placeDetails.result?.geometry?.location?.lat.toString();
  prediction.lng = placeDetails.result?.geometry?.location?.lng.toString();
  widget.getPlaceDetailWithLatLng!(prediction);
} catch (e) {
  var errorHandler = ErrorHandler.internal().handleError(e);
  _showSnackBar("${errorHandler.message}");
}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions