I am using flutter_map to add a map to my project. I am able to work with it and use its options. But I want something that I did not find in flutter_map.
I want to listen to a position change and get the last position when the user stops touching the screen. Like the onTapUp or onLongPressUp in the GestureDetector widget.
There is onPositionChanged option in flutter_map but it gets called every time the position is changing, which is a lot. As soon as the user touched the screen, the onPositionChanged gets called until the user stops touching the screen. I can get the last position from this, but I want to call an API when the position changes to get the list of nearby cars. Calling API every time the onPositionChanged gets called is not good.
So I want to be able to call the API when the user finishes changing location (when he/she stops touching the screen).
Here is my flutter_map code:
FlutterMap(
key: Key('map'),
mapController: main.mapController,
options: MapOptions(
center: LatLng(main.lat, main.long),
zoom: 14,
maxZoom: 18,
minZoom: 10,
onPositionChanged: (mapPosition, boolValue){
_lastposition = mapPosition.center;
}),
layers: [
TileLayerOptions(
errorImage: AssetImage('images/login_icon.png'),
urlTemplate:
"https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png",
// subdomains: ['a', 'b', 'c'],
// subdomains: ['', '1', '2', '3', '4']
),
MarkerLayerOptions(
markers: main.markersStart +
main.markersDestination +
main.driverMarkers,
),
],
),
Any help would be appreciated, thanks :).