kosukesaigusa / geoflutterfire_plus

πŸŒπŸ’™πŸ”₯ geoflutterfire_plus allows your flutter apps to query geographic data saved in Cloud Firestore. This package is fork from GeoFlutterFire, and tried to be constantly maintained to work with latest Flutter SDK, Dart SDK, and other dependency packages.
https://pub.dev/packages/geoflutterfire_plus
MIT License
59 stars 7 forks source link

Trying to configure this in Flutterflow: Not able to compile this. #218

Closed vairagadeharshwardhan closed 3 months ago

vairagadeharshwardhan commented 3 months ago

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.

kosukesaigusa commented 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.

kosukesaigusa commented 3 months ago

And Geoflutterfire is not found in this package. See README or example directory.