Skip to content
pubscout

geoflutterfire2

2.3.15, released 4 years ago by beerstorm.net

Realtime geo queries on Firestore using geohashes

WASM-ready
$ flutter pub add geoflutterfire2
Source repository

What it does

GeoFlutterFire2 lets you store geographic points in Firestore and query them in real‑time. It uses geohashes to limit Firestore reads to nearby documents, keeping apps light and responsive.

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

Use it when

  • Need to query Firestore documents by location in real time
  • Building map‑based apps that show nearby points
  • Working with large datasets where only nearby data should be loaded

Skip it when

  • Using the `within` method without cancelling the subscription, which can leak memory
  • Relying on it for non‑Firebase backends

Strengths

  • Realtime streaming of query results
  • Null‑safe and Flutter 2 compatible
  • Lightweight wrapper around cloud_firestore
  • Easy to write and read geo data

Weaknesses

  • Creates 9 underlying listeners per query, can leak memory if not cancelled
  • Only works with Firebase Firestore

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

Add `geoflutterfire2` to pubspec, initialize Firebase, import the package

```dart
import 'package:geoflutterfire2/geoflutterfire2.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

final geo = GeoFlutterFire();
final _firestore = FirebaseFirestore.instance;

// Write a point
final point = geo.point(latitude: 12.960632, longitude: 77.641603);
_firestore.collection('locations').add({'name': 'random', 'position': point.data});

// Query nearby points
final center = geo.point(latitude: 12.960632, longitude: 77.641603);
final stream = geo.collection(collectionRef: _firestore.collection('locations'))
    .within(center: center, radius: 50, field: 'position');
stream.listen((docs) => print('Found ${docs.length} docs'));
```

Alternatives

Packages that do the same job and could replace geoflutterfire2.

Works with

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