title: How to NOT show the current user in a Grid View?
body: <p>I have a function called <code>getAllUsers()</code> that returns all users from a database. The problem is that I want <code>GridView.builder()</code> to display all the users except the current user, but despite all the research I did, nothing seems to work out.</p>
  <p>If i use the if condition like <code>if(snapshot.data.documents[i].data[&quot;username&quot;] != currentUserId</code> within <code>itemBuilder:</code>, it returns a blank tile which represents the current user which creates a gap within the grid view. Thus, it makes the grid view look really bad.</p>
  <p>I believe this problem could have been solved if I knew how to include the inequality query in the <code>getAllUsers()</code> method. But my understanding is that Firestore has yet to provide this function/argument.</p>
  <p><strong>HomeFragment class</strong></p>
  <pre><code>  Database _database = Database();
    Stream _stream;
    String currentUserId;
  
    @override
    void initState() {
      getCurrentUserId();
      getAllUsers();
      super.initState();
    }
  
    getAllUsers() async {
      return await _database.getAllUsers().then((val) {
        if (mounted)
          setState(() =&gt; _stream = val);
      });
    }
  
    getCurrentUserId() async {
      FirebaseUser currentUser = await FirebaseAuth.instance.currentUser();
      currentUserId = currentUser.uid;
    }
  
    @override
    Widget build(BuildContext context) {
  
      return StreamBuilder(
        stream: _stream,
        builder: (context, snapshot) {
          return snapshot.data == null ? Center(child: CircularProgressIndicator())
              : Container(
            padding: EdgeInsets.symmetric(horizontal: 20.0),
            child:
                GridView.builder(
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                    crossAxisSpacing: 8.0,
                    mainAxisSpacing: 8.0,
                  ),
                  itemCount: snapshot.data.documents.length,
                  itemBuilder: (context, i) {
                      return Container(
                         child: Text(snapshot.data.documents[i].data[&quot;username&quot;])
                      );
                  }
                  // etc etc..
  </code></pre>
  <p><strong>Database class</strong></p>
  <pre><code>getAllUsers() async {
      return await _firestore.collection(&quot;users&quot;).snapshots();
  }
  </code></pre>
  <p>I tried to use this, but <code>_stream2</code> returns null</p>
  <pre><code>Stream _stream, _stream2;
  
      getAllUsers() async {
      return await _database.getAllUsers().then((val) {
        if (mounted) {
          List&lt;String&gt; list;
          setState(() {
            _stream = val;
            _stream2 = _stream.where((snapshot) {
              _querySnapshot = snapshot;
              for (int i = 0; i &lt; _querySnapshot.documents.length; i++)
                list.add(_querySnapshot.documents[i].data[&quot;userId&quot;]);
              return list.contains(currentUserId) == false;
            });
          });
        }
      });
    }
  </code></pre>
  <p>I also tried this, it is not working</p>
  <pre><code>getAllUsers() async {
      Stream&lt;QuerySnapshot&gt; snapshots = await _database.getAllUsers();
      _stream = snapshots.map((snapshot) {
        snapshot.documents.where((documentSnapshot) {
          return documentSnapshot.data[&quot;userId&quot;] != currentUserId;
        });
      });
    }
  </code></pre>