Closed vairagadeharshwardhan closed 3 months ago
Hello @vairagadeharshwardhan.
I'm sorry, but please do not paste your whole codes, but summarize and show a minimal reproducible codes.
And I think it's just related to your dependency configuration, but not something particular in this package.
And Geoflutterfire
is not found in this package. See README or example directory.
I want to get list of documents which are within radiusInKm (say 1 Km). I am storing lat and Lon in firebase database as field value which of LatLan type.
Please check following code:
// Automatic FlutterFlow imports import '/backend/backend.dart'; import '/backend/schema/structs/index.dart'; import '/backend/schema/enums/enums.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/custom_code/actions/index.dart'; // Imports other custom actions import '/flutter_flow/custom_functions.dart'; // Imports custom functions import 'package:flutter/material.dart'; // Begin custom action code // DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:geoflutterfire_plus/geoflutterfire_plus.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
class ClientNewLozyBookingRecord { final GeoPoint startPointLT_LG;
ClientNewLozyBookingRecord.fromFirestore(DocumentSnapshot doc) : startPointLT_LG = doc['start_point_LT_LG']; }
Future<List?> getNearByTrips(
int? radiusInKm,
double userLiveLocationLat,
double userLiveLocationLon,
) async {
// Create a GeoFlutterFire instance
final geo = Geoflutterfire();
// Create a reference to the collection
final collectionRef =
FirebaseFirestore.instance.collection('client_new_lozy_booking');
// Create a GeoFirePoint for the user's live location final userLocation = geo.point(latitude: userLiveLocationLat, longitude: userLiveLocationLon);
// Create a query to get all documents within the given radius of the user's location final query = geo.collection(collectionRef: collectionRef).within( center: userLocation, radius: radiusInKm!, field: 'start_point_LT_LG', );
// Execute the query and get the documents final documents = await query.first;
// Map the documents to ClientNewLozyBookingRecord objects final nearbyTrips = documents .map((doc) => ClientNewLozyBookingRecord.fromFirestore(doc)) .toList();
// Return the nearby trips return nearbyTrips; }
Error: The function 'Geoflutterfire' isn't defined. Try importing the library that defines 'Geoflutterfire', correcting the name to the name of an existing function, or defining a function named 'Geoflutterfire'.
Please guide me to solve this.