I am getting this error and do not know how to solve it:
var directions = LocationService().getDirections(
_originController.text, _destinationController.text);
_goToPlace(directions['start_location']['lat'], directions['start_location']['lng']);
setPolyline(directions['polyline_decoded']);
},
Below is the code of the _goToPlace() method:
Future<void> _goToPlace(double lat, double lng) async {
final GoogleMapController controller = await _controllerGoogleMap.future;
controller.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(
target: LatLng(lat, lng),
zoom: 12,
),
),
);
}
CodePudding user response:
Mark your function as async and put an await before your getDirections
await LocationService().getDirections(
_originController.text, _destinationController.text);
Your getDirections returns a Future, so you have await it.