Simplify code by using List.where

This commit is contained in:
Vishesh Handa
2019-09-25 17:10:37 +02:00
parent 784ce78a2d
commit f1732484d7

View File

@ -125,13 +125,10 @@ class NoteSearch extends SearchDelegate<Note> {
final appState = container.appState; final appState = container.appState;
// TODO: This should be made far more efficient // TODO: This should be made far more efficient
List<Note> filteredNotes = [];
var q = query.toLowerCase(); var q = query.toLowerCase();
appState.notes.forEach((note) { var filteredNotes = appState.notes.where((note) {
if (note.body.toLowerCase().contains(query)) { return note.body.toLowerCase().contains(q);
filteredNotes.add(note); }).toList();
}
});
Widget journalList = JournalList( Widget journalList = JournalList(
notes: filteredNotes, notes: filteredNotes,