Home > Enterprise >  Query with condition isNotEqualTo not work in flutter
Query with condition isNotEqualTo not work in flutter

Time:06-15

I have a problem with the query with the condition isNotEqualTo does not work and does not show the values ​​checked from the condition, note that I tried the condition isNotEqualTo and it worked What is the problem

_setStream() async {
    var pos = await location.getLocation();
    double lat = pos.latitude!;
    double lng = pos.longitude!;
    

    var ref = await FirebaseFirestore.instance.collection('now')
     .where('uid', isNotEqualTo: _user.uid).orderBy('uid');

    GeoFirePoint center = geo.point(latitude: lat, longitude: lng);

    stream = radius.switchMap((rad) {
      var collectionReference = ref;
      return geo.collection(collectionRef: collectionReference).within(
          center: center, radius: rad, field: 'location', strictMode: true);
    });

    setState(() {
      isLoading = false;
    });

    stream = geo.collection(collectionRef: ref).within(
        center: center, radius: 2000, field: 'location', strictMode: true);
    stream!.listen((List<DocumentSnapshot> documentList) {
      documentList.forEach((element) {
        print("from data .......element");
        print(element.data());
        final data = element.data() as Map<String, dynamic>;
        final GeoPoint point = data['location']['geopoint'];
        print("from data .......latitude");
        print(point.latitude);
      });
    });
  }

CodePudding user response:

Even though NotEqual query is available in firebase, it was made available late in flutter plugin. The best option is to fetch all to a list and remove unwanted elements from the list

  • Related