Can I disable specific days?
ayberkcal opened this issue ยท 5 comments
Version of flutter_calendar_carousel
2.0.3
I would like to disable some days.
For example I would like to users cannot select all Saturdays or Sundays. Also I would like to disable specific date. For example 12.09.2021 which is in between minday-maxday. How can I do it?
@hyochan how to disable some specific days in calendar
@ayberkcal you could pass the DateTime variable from the
onDayPressed: (){}
to handle the click and than write a function to know if it's a weekday or not.
For example (fast code.. be polite):
bool isWeekend(DateTime date) { DateTime tempDate = DateFormat("yyyy-MM-dd hh:mm:ss").parse(date.toString()); DateFormat dateFormat = DateFormat("EEEE"); String string = dateFormat.format(tempDate); if (string == 'Sunday' || string == 'Saturday') return true; return false; }
Than you can manage the state or do whatever u want with the click.
example:
onDayPressed: (DateTime date, List<Event> events) { if (isWeekend(date)) { // it's weekend yey } else { // no weekend :( } }
hope that helps :)
@ayberkcal you could pass the DateTime variable from the
onDayPressed: (){}
to handle the click and than write a function to know if it's a weekday or not.For example (fast code.. be polite):
bool isWeekend(DateTime date) { DateTime tempDate = DateFormat("yyyy-MM-dd hh:mm:ss").parse(date.toString()); DateFormat dateFormat = DateFormat("EEEE"); String string = dateFormat.format(tempDate); if (string == 'Sunday' || string == 'Saturday') return true; return false; }
Than you can manage the state or do whatever u want with the click.
example:
onDayPressed: (DateTime date, List<Event> events) { if (isWeekend(date)) { // it's weekend yey } else { // no weekend :( } }
hope that helps :)
Thank you Sir
This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.
Will it be displayed as disabled? I need it to be visible what days are selectabe