geoflutterfire2
2.3.15, released 4 years ago by beerstorm.net
Realtime geo queries on Firestore using geohashes
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.
- location_web
Web implementation of the location plugin for Flutter web.
74Compare - geoflutterfire
Store and query Firestore documents based on geographic location in real time.
50Compare - geoflutterfire_plus
Store and query Cloud Firestore documents based on geographic locations.
66Compare - flutter_geofire
Flutter plugin for realtime location queries using GeoFire and Firebase.
48Compare
Works with
Packages commonly used together with geoflutterfire2: ones it builds on, ones built on it, and its own family.