A Flutter plugin to use the GeoFire Api
For Flutter plugins for other products, see mrdishant@github
Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!
GeoFire — Realtime location queries with Firebase.
GeoFire is an open-source library that allows you to store and query a set of keys based on their geographic location.
At its heart, GeoFire simply stores locations with string keys. Its main benefit however, is the possibility of querying keys within a given geographic area - all in realtime.
GeoFire uses the Firebase database for data storage, allowing query results to be updated in realtime as they change. GeoFire selectively loads only the data near certain locations, keeping your applications light and responsive, even with extremely large datasets.
Initalize GeoFire with path to keys in Realtime Database
String pathToReference = "Sites"; Intializing geoFire Geofire.initialize(pathToReference);
Setting location data
Here setLocation method is used and first is the unique id of the place and other two parameters are latitude and longitude of that place.
bool response = await Geofire.setLocation( new DateTime.now().millisecondsSinceEpoch.toString(), 30.730743, 76.774948)
Retrieving a location
Retrieving a location for a single key in GeoFire happens like below:
Map<String, dynamic> response = await Geofire.getLocation("AsH28LWk8MXfwRLfVxgx"); print(response);
GeoFire allows you to query all keys within a geographic area using GeoQuery objects. As the locations for keys change, the query is updated in realtime and fires events letting you know if any relevant keys have moved. GeoQuery parameters can be updated later to change the size and center of the queried area.
response = await Geofire.queryAtLocation(30.730743, 76.774948, 5);
Removing a location
To remove a location and delete it from the database simply pass the location's key to removeLocation:
bool response = await Geofire.removeLocation("AsH28LWk8MXfwRLfVxgx"); print(response);
if you want to contribute to GeoFire, clone the repository and just start making pull requests.
git clone https://github.com/mrdishant/flutter_geofire
This plugin is in development suggestions are welcome. Happy Coding!!!
- Built-in types and core primitives for a Flutter application. [...]
- Support for asynchronous programming, with classes such as Future and Stream. [...]
- Classes and utilities that supplement the collection support in dart:core. [...]
- Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
- Built-in types, collections, and other core functionality for every Dart program. [...]
- Interact with developer tools such as the debugger and inspector. [...]
- Mathematical constants and functions, plus a random number generator. [...]
- Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]
- File, socket, HTTP, and other I/O support for non-web applications. [...]
- Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]