Flutter Google Maps, how to detect map area change by user, not by controller

Viewed 1160

I am using Google Maps to display markers on the map and other widgets to describe each marker on the map. I have successfully implemented when the user tab on a widget, the map area will change to make the matching marker to be the center of the map. I also have the 'Search this area' button to search the map area. The hard part is to control how to hide/display the 'Search this area' button. So far, I have implemented it to display when the map area is changed. However, it causes the button to appear every time the map area changed by the user tab on a widget.

I would like to only detect the map area change by the user manually such as pinch zoom in / out, drag etc.

1 Answers

You can use the Listener widget to listen for onPointerMove on your map. Like this,

Listener(
  onPointerMove: (move) {
     // This will trigger when a user will drag the map
  },
child: map);

Mind that onPointerMove is called many times during user drag and is not called when the user taps on map buttons like the map zoom buttons.

If you want only one call after the end of the user interaction and to also get events from the map buttons, you can use onPointerUp instead.

Related