Blockquote
I have a block of code in my flutter google map implementation like this:
Location _location = Location();
void _onMapCreated(GoogleMapController _cntrl) {
_controller = _cntrl;
_location.onLocationChanged.listen((l) {
print(l.latitude);
print(l.longitude);
_controller.animateCamera(
CameraUpdate.newCameraPosition(
CameraPosition(
target: LatLng(l.latitude, l.longitude),
zoom: 15
),
),
);
});
}
By this I am getting user's current Latitude and Longitude .
I want to store those longitude and latitude inside another 2 variables outside the function for further use. How would I do that??
My requirement is I want user's current longitude & latitude as the source point and another 2 hard coded longitude & latitude as destination point on flutter google map.
I just want to access those l.latitude & l.longitude outside the _onMapCreated(). Please help me out!