FabioFiuza / scrollable_clean_calendar

A calendar with vertical scroll
MIT License
35 stars 57 forks source link

dayBuilder rebuilds every time when I click onDayTapped #24

Open desmeit opened 2 years ago

desmeit commented 2 years ago

Is it correct that the calendar rebuilds its daybuilder each time it runs onDayTapped?

calendarController = CleanCalendarController(
      //minDate: DateTime.now(),
      //maxDate: DateTime.now().add(const Duration(days: 365)),
      minDate: DateTime(2021, 9, 2),
      maxDate: DateTime(2022, 3, 1),
      onRangeSelected: (firstDate, secondDate) {},
      onDayTapped: (date) {
        print("Clean Calendar: " + date.toString());

...

ScrollableCleanCalendar(
                  locale: language,
                  scrollController: _controller,
                  calendarController: calendarController,
                  layout: Layout.DEFAULT,
                  calendarCrossAxisSpacing: 0,
                  dayBuilder: (context, values) {
                    print("values day: " + values.day.toString());

This takes very long because it rebuilds all the days from scratch. II think it is not so good for the performance.

desmeit commented 2 years ago

What do you think about performance issues? if a calendar has many years and many months, for example, when a day should be customized by a click, all days have to be recalculated each time. how did you solve this?

rodrigodobbin commented 2 years ago

Thats a nice point o view @desmeit. When we made this calendar, we were focus on tourism type of business. So the calendar will justa have one year, maximum two years. So we do not care about perfomance issues due to the size of the calendar that we use in our daily products.

But we will investigate this, since it is important that the calendar work for every kind of business.

Thanks again for your feedback and report