Jason Simard
Jason Simard

Reputation: 133

Table_Calendar how to filter only the day of the month

I am currently filling a beautiful Table Calendar (https://pub.dev/packages/table_calendar)

To get my data I currently doing this:

            Firestore.instance
              .collection('nurseries')
              .document(widget._favoriteNurseryId)
              .collection('events')
              .orderBy('eventDateStart')
              .snapshots(),

I need to find a solution to filter data only for displayed month on the screen. For now i fetch all events on database. It cost me too many firestore Reads.

Upvotes: 2

Views: 1009

Answers (2)

Dipen Shah
Dipen Shah

Reputation: 26085

Update: I initially misunderstood the question. To get start and end date on the calendar you can either listen to on OnSelectedDaySelected and determine start and end dates based on calendar format.

Or

Listen to OnCalendarCreated and OnVisibleDaysChaned event callbacks to get start and end dates on the calendar.

Refer: https://pub.dev/documentation/table_calendar/latest/table_calendar/table_calendar-library.html

Sounds like you need to query the data instead of fetching everything. Following query should work:

Firestore.instance
  .collection('nurseries')
  .document(widget._favoriteNurseryId)
  .collection('events')
  .orderBy('eventDateStart')
  .startAt('startDate')   // startAfter
  .endAt('endDate')     // endBefore
  .snapshots()

Upvotes: 1

ElsayedDev
ElsayedDev

Reputation: 650

I couldn't understand you question well but, I think you search about

FieldValue.serverTimestamp()

Try it

Upvotes: 0

Related Questions