title: How to handle searching Large Lists in Flutter?
body: <p>I want to ask how I should handle a large list in Flutter. My app gets super slow when I am at a data item that is really deep in the list which I am searching. My list is 70,000+ objects of a data structure large.</p>
  
  <p>The following is how I am "Searching" the list.</p>
  
  <pre><code>Future&lt;Iterable&lt;SomeDataStruct&gt;&gt; _getAllData() async {
      return allData.where((a) =&gt; (a.dataTitle.toLowerCase().contains(querySearch.toLowerCase().trim())));
  }
  </code></pre>
  
  <p>Building the list using a ListView.builder inside of a FutureBuilder.</p>
  
  <p>When I search and a result or results from deep inside the list are populated the app is extremely slow to the point where I click a list item and it takes few seconds before it does its onTap. And if I need to change the search query it takes time for the soft keyboard to come back up after I click on the TextField.</p>
  
  <p>Where am I making a mistake or handling this wrong, what should I do to have my huge list searchable without making app unbearable.</p>
  
  <p><strong>EDIT:</strong>
  How I made it not slow down the app after change to code. Is this correct?</p>
  
  <pre><code>String tempQuery;
  List&lt;SomeDataStruct&gt; searchResults = [];
  Future&lt;List&lt;SomeDataStruct&gt;&gt; _getAllData() async {
      if(querySearch!=tempQuery) {
        tempQuery = querySearch;
        searchResults = allData.where((a) =&gt; (a.dataTitle.toLowerCase().contains(querySearch.toLowerCase().trim()))).toList();
      }
      return searchResults;
    }
  </code></pre>