Skip to content

Add single request functionality #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ dev_dependencies:
geoflutterfire2:
path: ../

cloud_firestore: ^4.1.0
google_maps_flutter: ^2.2.1
cloud_firestore: ^4.2.0
google_maps_flutter: ^2.2.2

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
Expand Down
20 changes: 18 additions & 2 deletions lib/src/collection.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import 'dart:async';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:rxdart/rxdart.dart';

import 'models/DistanceDocSnapshot.dart';
import 'point.dart';
import 'util.dart';

class GeoFireCollectionRef {
Query _collectionReference;

Stream<QuerySnapshot>? _stream;

GeoFireCollectionRef(this._collectionReference) {
Expand Down Expand Up @@ -77,6 +76,23 @@ class GeoFireCollectionRef {
}
}

Future<List<DocumentSnapshot>> get({
required GeoFirePoint center,
required double radius,
required String field,
required bool? strictMode,
}) {
return within(
center: center,
field: field,
radius: radius,
strictMode: strictMode = false,
)
.map((snapshots) =>
snapshots.map<DocumentSnapshot>((snapshot) => snapshot).toList())
.first;
}

/// query firestore documents based on geographic [radius] from geoFirePoint [center]
/// [field] specifies the name of the key in the document
Stream<List<DocumentSnapshot>> within({
Expand Down
22 changes: 11 additions & 11 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: _flutterfire_internals
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.9"
version: "1.0.10"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -42,21 +42,21 @@ packages:
name: cloud_firestore
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
version: "4.2.0"
cloud_firestore_platform_interface:
dependency: transitive
description:
name: cloud_firestore_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "5.9.0"
version: "5.9.2"
cloud_firestore_web:
dependency: transitive
description:
name: cloud_firestore_web
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
version: "3.1.1"
collection:
dependency: transitive
description:
Expand All @@ -77,7 +77,7 @@ packages:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.4.0"
firebase_core_platform_interface:
dependency: transitive
description:
Expand All @@ -91,7 +91,7 @@ packages:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.2"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -127,7 +127,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
version: "0.1.5"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -167,7 +167,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.1"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -202,14 +202,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.13"
version: "0.4.12"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.2"
sdks:
dart: ">=2.18.0-146.0.dev <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=1.20.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
cloud_firestore: ^4.1.0
cloud_firestore: ^4.2.0
rxdart: ^0.27.7

dev_dependencies:
Expand Down