arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Listen To Events

circle-info

To cause a widget inside FlutterMap's context to rebuild when an aspect changes, see .

When the state of a MapCamera changes, because of an update to its position or zoom, for example, a MapEvent, which can be handled by you.

hashtag
Catching All Events

There's two methods to catch all emitted MapEvents. These methods expose the raw MapEvent, and is recommended in cases where multiple events need to be caught, or there's no more specific callback method available in MapOptions (see ).

  • Listening to a 's mapEventStream, which exposes events via a Stream

  • Specifying a callback method in MapOptions.onMapEvent

hashtag
Catching Specific Events

If only a couple of events need to be caught, such as just an onTap handler, it is possible to avoid handling the raw Stream of MapEvents. Instead, MapOptions has callbacks available for the following events:

  • onTap

  • onLongPress

  • onPositionChanged

circle-info

The MapEventTap event may be emitted (or the onTap callback called) 250ms after the actual tap occurred, as this is the acceptable delay between the two taps in a double tap zoom gesture.

If this causes noticeable jank or a bad experience (for example, on desktop platforms), disable .doubleTapZoom:

This disables the double tap handler, so the MapEventTap

onPointerDown/onPointerUp/onPointerHover/onPointerCancel

  • onMapReady Primarily used for advanced MapController

  • is emitted 'instantly' on tap.
    options: MapOptions(
        interactiveFlags: ~InteractiveFlag.doubleTapZoom,
    ),
    MapController
    InteractiveFlag
    Catching Specific Events
    2. Hooking Into Inherited State
    Controllers & Cameras