I tried to determine my address's camera position by using 'geolocator' library but I don't know how to set it into the google map's initial camera position
searchAndNavigate() {
searchAddress = widget.author.address;
Geolocator().placemarkFromAddress(searchAddress).then((result) {
mapController.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
target:
LatLng(result[0].position.latitude, result[0].position.longitude),
zoom: 10.0)));
});
}
void onMapCreated(controller) {
setState(() {
mapController = controller;
});
}
Widget mapSection = Container(
height: 400,
width: 400,
child: Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
child: GoogleMap(
onMapCreated: onMapCreated,
initialCameraPosition: CameraPosition(
target: LatLng(40.7128, -74.0060), zoom: 10.0)),
),
);
@override
void initState() {
super.initState();
searchAndNavigate();
}