Back to Projects

GeoQueryFirestore

Advanced Geospatial Queries for Firestore

FlutterDartSWEFirebaseFirestore
GeoQueryFirestore

GeoQueryFirestore is an open-source Dart package that solves one of Firestore’s biggest limitations: performing performant geospatial queries at scale. It enables developers to filter location-based data with support for pagination, limits, and ordering—features often missing in standard solutions.

The Problem: Firestore's Geo-Query Gap

While Firestore is powerful, its native support for location-based searches is limited. Developers often struggle with:

  • No Pagination → Loading thousands of nearby locations at once, causing crashes and high costs.
  • Missing Sort/Limit → Inability to retrieve only the "closest 20" items or sort by a secondary field.
  • Performance Bottlenecks → High latency when querying large datasets using standard geofence methods.
  • Inflexible Ranges → Difficulties in handling custom search radii or map-view boundaries.

Existing tools like GeoFlutterFire provided a start, but couldn't handle production-grade enterprise needs.

The Solution: A Robust Geo-Engine for Dart

GeoQueryFirestore (available on GitHub) operates by intelligently selecting geohash precision based on the search area. It treats location data as a first-class citizen, allowing for complex queries that feel native to Firestore.

Core Capabilities:

  1. Query by Range → Search within a specific radius (e.g., 10km) with automatic precision adjustment.
  2. Map Bounds Search → Fetch only the documents currently visible on a user's map screen (LatLngBounds).
  3. Built-in Pagination → Effortlessly "load more" results as the user scrolls, saving bandwidth and memory.
  4. Order & Limit → Combine location filters with limit() and orderBy() to show the most relevant data first.

Why It’s a Game Changer

  • Scale-Ready → Specifically designed to handle large datasets where loading everything at once isn't an option.
  • Intelligent Precision → Automatically calculates the optimal geohash length to minimize read operations and maximize speed.
  • Developer Friendly → A clean, intuitive API that integrates seamlessly with existing cloud_firestore projects.
  • Customizable → Supports both predefined ranges and custom meter-based search distances.

The Impact (Open Source Contribution)

  • Bridged the Gap → Created a solution for features (pagination/ordering) that the community had requested for years.
  • Optimization → Reduced unnecessary document reads by optimizing how geohash cells are calculated and queried.
  • Public Utility → Provided as a free, open-source package to help Flutter developers build better location-based apps.

Technical Highlights

Built for the Flutter/Dart ecosystem with a focus on performance:

  • Geohash Algorithm for converting coordinates into searchable string prefixes.
  • Custom Precision Logic to balance search accuracy with query performance.
  • Paging Controller logic that automatically tracks document snapshots for seamless "next page" fetches.
  • LatLngBounds Filtering for strict boundary adherence in map-heavy applications.

My Role: Creator & Maintainer

I identified the technical gap while building location-heavy products and decided to build and open-source the solution.

  • Problem Identification → Recognized the scaling issues with existing Firestore geo-libraries.
  • Library Architecture → Designed the core logic for geohash precision and query concatenation.
  • Documentation & Examples → Wrote comprehensive guides to help other developers implement complex geo-features in minutes.

The result? A go-to tool for Flutter developers who need reliable, paginated, and fast location queries in Firestore.