Search packages, repositories and app categories

fluster cover
Package detailsv1.2.0

fluster

A geospatial point clustering library for Dart to help provide spacing between markers in mapping solutions.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
14.3K
Likes
134
Pub points
150

Install package

flutter pub add fluster

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Fluster is a geospatial point clustering library for Dart, designed to efficiently group and manage map markers in mapping applications. It helps prevent marker overcrowding by dynamically clustering points based on zoom level and spatial proximity. Ideal for performance optimization in maps with large datasets, Fluster ensures smooth user experiences across platforms. The library integrates seamlessly into Flutter apps and supports multiple platforms including Android, iOS, Web, macOS, Windows, and Linux.

Use cases

  • Large-scale map marker visualization
  • Real-time location tracking with dense data
  • Performance optimization in mapping UIs
  • Dynamic clustering based on zoom level
  • Map-based analytics dashboards

Key features

  • Efficient spatial clustering algorithm
  • Zoom-level adaptive clustering
  • Cross-platform support (Android, iOS, Web, macOS, Windows, Linux)
  • Lightweight and fast processing
  • Easy integration with Flutter map widgets

Suitable for

  • Developers building interactive maps
  • Apps with high-density location data
  • Location-based services requiring performance
  • Flutter developers using Google Maps or similar plugins
  • Projects needing scalable marker management

Considerations

  • Best suited for static or semi-static datasets
  • May require tuning for very high-frequency updates
  • Limited to point clustering (not polygon or line features)
  • Depends on accurate coordinate input
  • Not optimized for offline clustering scenarios

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Build Status Pub

Fluster = Flutter + Cluster

A geospatial point clustering library for Dart (Flutter not actually required). The algorithm is a Dart port of supercluster.

Image

Usage

Implement Clusterable

Fluster will cluster a List of objects that conform to the Clusterable abstract class, which includes necessary information such as latitude and longitude:

class MapMarker extends Clusterable {
  String locationName;
  String thumbnailSrc;

  MapMarker(
      {this.locationName,
      latitude,
      longitude,
      this.thumbnailSrc,
      isCluster = false,
      clusterId,
      pointsSize,
      markerId,
      childMarkerId})
      : super(
            latitude: latitude,
            longitude: longitude,
            isCluster: isCluster,
            clusterId: clusterId,
            pointsSize: pointsSize,
            markerId: markerId,
            childMarkerId: childMarkerId);
}
Set up Fluster

Create a Fluster instance once you have a set of points you'd like to cluster:

List<MapMarker> markers = getMarkers();

Fluster<MapMarker> fluster = Fluster<MapMarker>(
      minZoom: 0,
      maxZoom: 20,
      radius: 150,
      extent: 2048,
      nodeSize: 64,
      points: markers,
      createCluster: (BaseCluster cluster, double longitude, double latitude) {
        return MapMarker(
            markerId: cluster.id.toString(),
            latitude: latitude,
            longitude: longitude);
      });

Parameters:

/// Any zoom value below minZoom will not generate clusters.
int minZoom;

/// Any zoom value above maxZoom will not generate clusters.
int maxZoom;

/// Cluster radius in pixels.
int radius;

/// Adjust the extent by powers of 2 (e.g. 512. 1024, ... max 8192) to get the
/// desired distance between markers where they start to cluster.
int extent;

/// The size of the KD-tree leaf node, which affects performance.
int nodeSize;

/// The List to be clustered.
List<T> points;

/// A callback to generate clusters of the given input type.
T Function(BaseCluster, double, double) createCluster;
Get the clusters

You can then get the clusters for a given bounding box and zoom value, where the bounding box = [southwestLng, southwestLat, northeastLng, northeastLat]:

List<MapMarker> clusters = fluster.clusters([-180, -85, 180, 85], _currentZoom);
Get the cluster children

You can also get the children (points and sub-clusters inside a cluster at the next zoom level, given the cluster id:

List<MapMarker> chilren = fluster.children(int clusterId);
Get the cluster points

Get only the child points (not sub-clusters) of a cluster in all the remaining zoom levels, given the cluster id:

List<MapMarker> points = fluster.points(clusterId);

Categories

Source repository

Projects using this package