Skip to content
pubscout

supercluster

3.2.0, released a year ago by balanci.ng

Fast point clustering library for maps supporting immutable and mutable indices.

WASM-ready
$ flutter pub add supercluster
Source repository

What it does

Provides fast point clustering algorithms ported from MapBox's supercluster library. It supports both immutable clustering and a mutable clustering variant for adding or removing points dynamically.

AI-written summary of version 3.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to cluster large sets of geographical points on a map efficiently
  • You require support for dynamically adding and removing points from clusters

Skip it when

  • You do not need geospatial clustering functionality

Strengths

  • Extremely fast point clustering algorithms
  • Supports both immutable and mutable indexing approaches
  • Allows efficient batch operations like addAll and removeAll

Weaknesses

  • Mutable clustering has performance costs compared to immutable loading
  • Limited to point clustering functionality

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
4
void main() {
  final points = [
    MapPoint(name: 'first', lat: 46, lon: 1.5),
    MapPoint(name: 'second', lat: 46.4, lon: 0.9),
    MapPoint(name: 'third', lat: 45, lon: 19),
  ];
  final supercluster = SuperclusterImmutable<MapPoint>(
    getX: (p) => p.lon,
    getY: (p) => p.lat,
  )
    ..load(points);

  final clustersAndPoints = supercluster.search(0, 40, 20, 50, 5);
}

Alternatives

Packages that do the same job and could replace supercluster.

Works with

Packages commonly used together with supercluster: ones it builds on, ones built on it, and its own family.