title: How to compare multiple fields in a query from Firestore?
body: <p>I'm trying to find a way to compare the location of all users and show nearby people as a result. <a href="https://stackoverflow.com/questions/58704323/how-to-search-and-send-notifications-to-people-nearby-in-flutter-firebase-app">In this question</a>, Frank explains how it should be done. But I have no idea how to do the third step.</p>
  <p>That's what I've achieved so far:</p>
  <pre><code>double _userLatitude;
  double _userLongitude;
  
  _getUserLocation() async {
      Position position = await Geolocator.getCurrentPosition(
          desiredAccuracy: LocationAccuracy.high);
  
      _userLatitude = position.latitude;
      _userLongitude = position.longitude;
  
      final firebaseUser = await FirebaseAuth.instance.currentUser();
      if (firebaseUser != null)
        await usersRef.document(firebaseUser.uid).updateData({
          &quot;location&quot;: &quot;active&quot;,
          &quot;latitude&quot;: _userLatitude,
          &quot;longitude&quot;: _userLongitude,
        });
    }
  
  _getNearbyUsers() {
      usersRef.where('location', isEqualTo: &quot;active&quot;).getDocuments();
  
      Geolocator.distanceBetween(
          _userLatitude, _userLongitude, endLatitude, endLongitude);
    }
  
  StreamBuilder(
          stream: _getNearbyUsers(),
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.waiting) {
              return Center(
                child: Text(
                  &quot;Loading...&quot;,
                ),
              );
            } else if (snapshot.data.documents.length == 1) {
              return Center(
                child: Text(
                  &quot;:/&quot;,
                ),
              );
            }
            return ListView.builder(
                padding: EdgeInsets.only(top: 10),
                scrollDirection: Axis.vertical,
                itemCount: snapshot.data.documents.length,
                itemBuilder: (context, index) =&gt;
                    _buildListUsers(context, snapshot.data.documents[index]));
          },
        ),
  
   Widget _buildListUsers(BuildContext context, DocumentSnapshot document) {
      List&lt;Users&gt; usersList = [];
      var data = document.data;
      if (data[&quot;id&quot;] != _userId) {
        Users user = Users();
        user.id = document[&quot;id&quot;];
  
        usersList.add(user);
        return ListTile(
          onTap: () {
            Navigator.pushNamed(context, &quot;/users&quot;, arguments: user);
          },
          title: Text(
                    document['id'],
                ),
        );
      }
      return SizedBox();
    }
  </code></pre>
  <p>I have no idea what to do next in _getNearbyUsers().</p>