Please help. I am trying to get the initialCameraPosition to programmatically display the current location of a user on a map. I don't want to hard code it. I have a getCurrentLocation method but I can't seem to use the result (its lat and lon) as the latitude and longitude of the initialCameraPosition of the Map.
the getCurrentLocation method is
Future<Position> getCurrentPosition() async {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print(position);
return position;
}
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
children: <Widget>[
GoogleMap(
initialCameraPosition:
CameraPosition(target: LatLng(9.0765, 7.3986), zoom: 17),//these coordinates should not be hard coded
onMapCreated: _onMapCreated,
myLocationEnabled: true,
mapType: MapType.normal,
markers: _marker,
),}