I want to filter data from the database by date, but I can't do it. As a result, only the Note for the month I need should be output.
I tried to do filtering, but I get an error:
Class 'Note' has no instance method '[]'. 
Receiver: Instance of 'Note' 
Tried calling: []("noteDate")
NoteList class
final List _allNotes = [];
  List<Map<String, dynamic>> _foundNotes = [];
  @override
  initState() {
    for (var note in notesModel.entityList) { _allNotes.add(note); }
    print('_allNotes = $_allNotes');
    // at the beginning, all users are shown
    _foundNotes = _allNotes.cast<Map<String, dynamic>>();
    _runFilter(date.month);
    super.initState();
  }
  void _runFilter(date) {
    List<Map<String, dynamic>>? results = [];
    print(date);
    print(_allNotes);
    if (date == null) {
      results = _allNotes.cast<Map<String, dynamic>>();
    } else {
      results = _allNotes
          .where((note) => note['noteDate'].contains(date)).cast<Map<String, dynamic>>()
          .toList();
    }
    // Refresh the UI
    setState(() {
      _foundNotes = results!;
      print('## _runFilter setState() ${_foundNotes}');
    });
  }
Note class:
class Note {
/// The fields this entity type contains.
int? id;
String? title;
String? content;
String? mood;
String? noteDate; // YYYY,MM,DD
String? noteTime; // HH,MM
/// Just for debugging, so we get something useful in the console.
String toString() {
return "{id: $id, title: $title, content: $content, color: $mood, noteDate: $noteDate, noteDate: $noteTime}";
}
}
Also, I can't get the notes data right away when I run the code