Search packages, repositories and app categories

Package detailsv3.0.2

r_tree

R-tree implementation to index and query two-dimensional data

AndroidiOSWebmacOSWindowsLinux
30-day downloads
20.3K
Likes
11
Pub points
145

Install package

flutter pub add r_tree

Package Overview

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

The r_tree package provides an R-tree implementation for efficiently indexing and querying two-dimensional spatial data in Dart. It enables fast range queries and nearest-neighbor searches, making it ideal for applications involving geographic coordinates, collision detection, or layout management. Built for performance and compatibility across platforms, it supports Android, iOS, Web, macOS, Windows, and Linux. The package is maintained by Workiva and integrates seamlessly with Flutter projects via pub.

Use cases

  • Spatial data indexing
  • Collision detection in games
  • Geographic coordinate queries
  • UI element hit testing
  • Proximity-based search
  • Map-based application features

Key features

  • Efficient 2D range queries
  • Support for nearest-neighbor searches
  • Cross-platform compatibility
  • High-performance spatial indexing
  • Simple API for insertion and querying
  • Thread-safe operations

Suitable for

  • Game development
  • GIS applications
  • Interactive UIs with spatial logic
  • Data visualization tools
  • Location-aware apps
  • Performance-critical spatial operations

Considerations

  • Best suited for 2D data only
  • Not optimized for very large datasets without partitioning
  • Requires careful handling of coordinate precision
  • Limited to static or batch-updated data in some use cases
  • No built-in persistence support

Original README

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

RTree Build Status

A recursive RTree library written in Dart. This R-tree implementation is used to index and query two-dimensional data. Items are inserted and balanced via the RTree class and can then be queried by Rectangle. The balancing can be tweaked by modifying the branch factor of the RTree.

"R-trees are tree data structures used for spatial access methods, i.e., for indexing multi-dimensional information such as geographical coordinates, rectangles or polygons." - http://en.wikipedia.org/wiki/R-tree

Example

Run the example app for a visual demonstration of the RTree

webdev serve example:8080

Navigate to http://localhost:8080. A canvas is drawn, click & drag on the canvas to add rectangles of various colors to your RTree, then click the search button and click & drag over an area of the canvas to search it for rectangles.

Benchmarks

Run the benchmarks in the command line (Dart VM) using:

dart benchmark/benchmarks.dart

You can also run them in a browser using dart2js. This takes an extra step since webdev will only build the web directory as of this writing. You'll also need some binary for serving a directory on a web server, the example below uses serve.

cp -R benchmark/ web
webdev build
serve build

Click the run button and observe the output in the browser console.

Categories

Source repository

Projects using this package

No data available yet.