Here we will see how to update camera position using flutter google map. First make sure you use GoogleMap() widget and create a google map object in your widget tree.
At the same time make sure that, you have created initial value for Camera Position.
CameraPosition _cameraPosition=CameraPosition(target:
LatLng(45.521563, -122.677433),zoom: 17);
If you class is stateful class, make sure that you initialize value before build() method.
Then inside GoogleMap() widget, we need to give value for initialCameraPosition property.
GoogleMap(
initialCameraPosition: CameraPosition(target: _initialPosition, zoom: 17),
onTap: (latLng) {
},
zoomControlsEnabled: false,
compassEnabled: false,
indoorViewEnabled: true,
mapToolbarEnabled: false,
myLocationEnabled: true,
onCameraIdle: () {
print("tapping for udpate");
//locationController.updatePosition(_cameraPosition, true);
},
onCameraMove: ((position){
_cameraPosition = position;
}),
onMapCreated: (GoogleMapController controller) {
//locationController.setMapController(controller);
//locationController.getCurrentLocation(true, mapController: controller);
},
)
As you can see, get position object for onCameraMove property. Position object is given to _cameraPosition.
More about google map on flutter geocoding.
But of course, you need to decode the position object using LatLng() class.