Plugins
Extension packages build on package:flutter_unified_map/plugin_api.dart, in the spirit of flutter_map's own
plugin API. The first one is the marker cluster.
Marker clustering
flutter_unified_map_marker_cluster — GitHub —
animates clusters on the native maps with the API of flutter_map_marker_cluster: MarkerClusterLayerWidget,
MarkerClusterLayerOptions, animated split and merge, spiderfy. On web, Windows and Linux it runs the real
flutter_map_marker_cluster inside the map (through FlutterMapLayer), so the clustering looks the same everywhere.
Its demo is one cluster over Brussels: zoom in and the pins dispatch over the area, zoom out and they pack back into the one cluster —

— and when zooming cannot split pins that share one point, a tap on their cluster spiderfies it: the pins glide out on a spiral, each with a leg back to the cluster, and a map tap folds them back in.

MarkerClusterLayerWidget(
options: MarkerClusterLayerOptions(
markers: markers,
maxClusterZoom: 10,
onClusterTap: (controller, cluster) => controller.animateTo(
dest: cluster.latLng,
zoom: cluster.zoom + 2,
),
),
)
Creating plugins
- a layer is a
MapLayerState: it receives an id, publishes markers throughMarkerPublisher(rasterised once per icon key), and pushes its shapes to the platform with each frame's diff; MapLayerHostexposes the camera (liveCamerawhile moving,idleCamerawhen settled),integerZoom, andsetFlutterMapLayersfor backends that can host flutter_map's own layer widgets;- markers animate through
MarkerTransition(appearFrom,disappearTo, glide) with the platform's easing; - icons are rasterised by
host.icons, anIconCachekeyed by icon key, logical size and pixel ratio, which rasterises a widget once and gives every image a unique key, so a diff only re-sends a marker whose image changed.
The marker cluster package is the reference implementation — read its source alongside the API.
Icons captured before they are ready
A native map takes a bitmap, not a widget, so every icon goes through WidgetRasterizer.render. A widget that paints
asynchronously — an SvgPicture, a network or asset image, anything behind a future — paints nothing, or something
different, on the frame it is first captured. The rasteriser waits for it: it captures the widget off-screen every
settleDelay (16 ms) until two consecutive captures paint exactly the same thing and nothing else is pending, for at
most settleTime (maxSettleTime, 2 s). A capture that paints nothing never counts as settled, and neither does a
tree still holding an image being decoded or a box taking up room with nothing in it — what an asynchronous painter
leaves where its picture will go. At most maxConcurrentRenders (4) widgets are rasterised at a time, so each one
gets its settle budget in wall-clock time instead of spending it queued behind the others.
render therefore returns a RasterizedWidget, not bytes alone:
final raster = await WidgetRasterizer.render(icon, logicalSize: size, pixelRatio: ratio, context: context);
raster.bytes; // what the widget showed, at the deadline if it never settled
raster.settled; // false: the capture may be wrong, rasterise it again later
IconCache acts on that flag so a wrong bitmap never outlives the frame it was captured on: an unsettled icon is
still published — the marker has to show something — but lookup reports it as missing, so the next resolve
rasterises it again, up to maxRenderAttempts (3). An icon waiting on an asset that is read by then comes out right
on the second pass.
Two things make an icon rasterise right the first time:
- give it a stable icon key, and prefer a pre-rendered image (
Image.memory) over a painter that decodes at build time — a deterministic icon settles on the second capture; - do not leave a sized empty box inside an icon. One left empty on purpose cannot be told from one about to be filled, so an icon holding a spacer is only returned at the deadline: size its neighbours or use padding instead.
Sharing code with a flutter_map app
FlutterMapLayer(child: ...) puts a raw flutter_map layer inside UnifiedMap: drawn inside the map on web,
Windows and Linux; ignored on the native maps (Android, iOS, macOS). Use it to share code with an existing
flutter_map app while the native backends take over.