title: How To Compare Objects By Name In Query Flutter by Property
body: <p>I am adding a search bar in my application and trying to query a object by an attribute name but, cant get it working.</p>
  
  <p>EDIT 1) Future function:</p>
  
  <pre><code> Widget _buildDiner() {
          return Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: &lt;Widget&gt;[
                    FutureBuilder(
                        future: _setDiner,
                        builder: (context, AsyncSnapshot snapshot) {
                          var diner = snapshot.data;
  
  
  
                          if (snapshot.data == null) {
                            return Center(child: CircularProgressIndicator());
                          } else {
                            var sponsoredDiner = diner
                                .where((e) =&gt; e.sponsored == 'Yes')
                                .toList();
  
  
                            return Column(
                              children: &lt;Widget&gt;[
                                _makeDiner(sponsoredDiner),
                                _buildCoupon(),
                                _buildVendors()
                              ],
                            );
                          }
                        })
                  ]));
        }
  </code></pre>
  
  <p>Diners = </p>
  
  <pre><code>class Diners {
    String keyword;
    int id;
    String name;
    String sponsored;
  
    Diners({
      this.keyword,
      this.id,
      this.name,
      this.sponsored
    });
  
    factory Diners.fromJson(Map&lt;String, dynamic&gt; parsedJson) {
      return Diners(
          keyword: parsedJson['keyword'] as String,
          id: parsedJson['id'],
          name: parsedJson['name'] as String,
          sponsored: parsedJson['sponsored'] as String
      );
    }
  }
  </code></pre>
  
  <p>And I am comparing two instances of Diners( sponsored and diners)</p>
  
  <p>I use this query to attempt to compare the text that is put in to the search bar:</p>
  
  <pre><code>final suggestionList = query.isEmpty
          ? sponsored
          : diners
              .where((p) =&gt; p.name.startsWith(query)).toList();
  </code></pre>
  
  <p>But I'm getting this error</p>
  
  <p>"type '(dynamic) => dynamic' is not a subtype of type '(Diner) => bool' of 'test'</p>
  
  <p>I'm not sure why</p>