dooboolab-community / flutter_calendar_carousel

Calendar widget for flutter that is swipeable horizontally. This widget can help you build your own calendar widget highly customizable.
MIT License
837 stars 307 forks source link

Can I disable specific days? #286

Closed ayberkcal closed 2 years ago

ayberkcal commented 3 years ago

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?

Scienticious commented 2 years ago

@hyochan how to disable some specific days in calendar

LeonBraeunig commented 2 years ago

@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 :)

peacemaker123456 commented 2 years ago

@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

github-actions[bot] commented 2 years ago

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.

giaur500 commented 1 year ago

Will it be displayed as disabled? I need it to be visible what days are selectabe