title: filter a list with multiple dropdowns in dart
body: <p>hey there thanks for checking out my question, i am making a app that connects to an api and pulls back the json data like so</p>
  
  <p><a href="https://i.stack.imgur.com/YCMpl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YCMpl.png" alt="main screen"></a>
  i have been trying to get a filter system to work so for example the list can be sorted by a certain series and other options, i have two lists in the code one for all of the results from the api called _userdetails and one for the search result called _searchresult.</p>
  
  <p>my goal is to have the filters and search bar working in sync, so for example you could filter for a series called one piece and then filter that new list with the other filters to narrow down the results and even use the search bar on these new lists.</p>
  
  <p>at the moment i have the filters working to a extent if the series is selected as dragonball it will select all of the dragon ball characters but once a new filter or the search is used it just resets the list
  here is the code for the dropdown</p>
  
  <pre><code>new Row(
            mainAxisAlignment: MainAxisAlignment.start,
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
                  children: &lt;Widget&gt;[
                   // Text("Select a series"),
  
  
                  new  DropdownButton&lt;String&gt;(
                      hint: Text("Series"),
                     // value: null,
  
                      items: _fieldList.map((value){
                        return DropdownMenuItem&lt;String&gt;(
                          value: value.series,
                          child: Container(
                            width: 100,
                          child: new Text(value.series),
                         // height: 5.0,
                            ),
                        );
                      }).toList(),
                      onChanged: (String val) {
                        _selectedText = val;
                        setState(() {
                         // _searchResult.clear();
                        //  _searchResult.removeWhere((userDetail) =&gt; userDetail.series != _selectedText);
                           // _newList.clear();
                          _selectedText = val;
                          _userDetails.forEach((userDetail) {
  
                            if(userDetail.series.contains(_selectedText)){
                              userDetail.remove((userDetail) =&gt; userDetail.series != _selectedText);
                              _searchResult.add(userDetail);}
                            if(_searchResult.contains(_selectedText))
                              _searchResult.removeWhere((userDetail) =&gt; userDetail.series != _selectedText);
  
                            //   _userDetails.where((f) =&gt; f.series.contains(_selectedText)).toList(); //apples
  
                            print(_searchResult.length);
  
                          });
                          print(_selectedText);
                        });
                      },
                    ),
  
                   new DropdownButton&lt;String&gt;(
                      hint: Text("Class"),
                      // value: null,
  
                      items: _fieldList.map((value){
                        return DropdownMenuItem&lt;String&gt;(
                          value: value.classs,
                          child: new Text(value.classs),
                        );
                      }).toList(),
                      onChanged: (String val) {
                        _selectedText = val;
                        setState(() {
  
                          _searchResult.removeWhere((userDetail) =&gt; userDetail.classs != _selectedText);
  
                          _userDetails.forEach((userDetail) {
                          if (userDetail.classs.contains(_selectedText))
                            ///loops thrpugh each user detail and add where selectedtext = whatever
                          //  _searchResult.removeWhere((_searchResult) =&gt; userDetail.classs != _selectedText);
                            _searchResult.removeWhere((userDetail) =&gt; userDetail.classs != _selectedText);
  
                          _searchResult.add(userDetail);
                        //  _userDetails.where((f) =&gt; f.classs.contains(_selectedText)).toList(); //apples
  
                         /// _searchResult.add(userDetail);
  
                          });
  
                             // _searchResult.add(userDetail);
                            print(_selectedText);
                            //_searchResult.remove(userDetail.classs.)
  
                            //_newList.add(userDetail);
                            print(_searchResult.length);
  
                         // });
                          print(_selectedText);
                        });
                      },
                    ),
                    SizedBox(
                      height: 5.0,
                    ),
                    Text('Selected: ${_selectedText}'),
                  ],
                ),
  </code></pre>
  
  <p>here is the code for the listview</p>
  
  <pre><code>new Expanded(
              child: _searchResult.length != 0 || controller.text.isNotEmpty
                  ? new ListView.builder(
                itemCount: _searchResult.length,
                itemBuilder: (context, i) {
                  return new Card(
                    child: new ListTile(
                      leading: new CircleAvatar(backgroundImage: new NetworkImage("https://ochd.co.uk/db/puti/Assets/Portraits/"+_searchResult[i].portrait,),),
                      title: new Text(_searchResult[i].name),
                      subtitle: new Text(_searchResult[i].classs),
                      onTap: () {
                        Navigator.push(context, new MaterialPageRoute(builder: (context) =&gt; DetailPage(_searchResult[i])));},
                    ),
                    margin:
                    const EdgeInsets.all(0.0),
                  );
                },
              )
                  : new ListView.builder(
                itemCount: _userDetails.length,
                itemBuilder: (context, index) {
                  return new Card(
                    child: new ListTile(
                      leading: new CircleAvatar(backgroundImage: new NetworkImage("https://ochd.co.uk/db/puti/Assets/Portraits/"+_userDetails[index].portrait,),),
                      title: new Text(_userDetails[index].name),
                      subtitle: new Text(_userDetails[index].classs),
                      trailing: new CircleAvatar(backgroundImage: new NetworkImage("https://ochd.co.uk/db/puti/Assets/"+_userDetails[index].type,),),
                      onTap: () {
                        Navigator.push(context, new MaterialPageRoute(builder: (context) =&gt; DetailPage(_userDetails[index])));},
                    ),
                    margin: const EdgeInsets.all(0.0),
                  );
                },
              ),
  
            ),
  </code></pre>
  
  <p>im a little bit stumped lol</p>