search method Null safety

List<LocationResult> search(
  1. double latitute,
  2. double longitude
)

Implementation

List<LocationResult> search(double latitute, double longitude) {
  var result = <LocationResult>[];
  var point = {'latitude': latitute, 'longitude': longitude};
  var nearest = _kdTree.nearest(point, numMarkers);
  var searchData = SearchData(latitute, longitude);

  nearest.forEach((x) {
    var location = LocationData.fromJson(x[0]);
    double distance = x[1];
    var bearing = _calculateBearing(
        location.latitude, location.longitude, latitute, longitude);
    result.add(LocationResult(location, distance, bearing, searchData));
  });

  return result;
}