if we search for any text in the search bar …we get filtered search results… but the issue is that all other To-dos are gone ..
I cant get back to all other Todos ..
search function code
List<Todos> todList =[];
searchTodo(String enterdText) {
final search = todList.where((txt) {
final inputtext = txt.todoText.toLowerCase();
final input = enterdText.toLowerCase();
return inputtext.contains(input);
}).toList();
setState(() => {todList = search});
}
search bar
TextField(
onChanged: searchTodo,
decoration: InputDecoration(
hintText: 'Search',
prefixIcon: Icon(Icons.search_rounded),
// enabledBorder: InputBorder.none,
iconColor: Colors.grey.shade400,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20))),
),
2
Answers
Save your list to a different variable and once the search ends replace with the saved list.