flutter moor query filter with date


I want to get a stream of record which are in the same day of input (like all records with date of Feb 23, 2020).

Stream<List<BloodSugar>> watchBloodSugarsInDate(DateTime date) {

    return (select(bloodSugarsEntity)
          ..where((bp) => bp.date.equals(date)))
        .map((bloodSugarsEntity) => convertEntityToModel(bloodSugarsEntity))

this is my code and it doesn’t work because dateTime is combine of date and time. I tried using nested queries for separated comparison of year, month and day but I couldn’t make it.
Any help would be much appriciated.


  bool isSameDate(bp) {
    final value = bp.date;

    return value.year == date.year &&
        value.month == date.month &&
        value.day == date.day;

Answered By – Kahou

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *