Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to upgrade TableCalendar in table_calendar package? #636

Closed
sarohabhawna opened this issue Dec 13, 2021 · 3 comments
Closed

How to upgrade TableCalendar in table_calendar package? #636

sarohabhawna opened this issue Dec 13, 2021 · 3 comments

Comments

@sarohabhawna
Copy link

I'm using table_calendar in a flutter project. I upgraded it from ^2.3.3 to ^3.0.3

This is how the class was used earlier

TableCalendar(
      calendarController: _calendarController,
      events: _events,
      initialCalendarFormat: CalendarFormat.month,
      formatAnimation: FormatAnimation.slide,
      startingDayOfWeek: StartingDayOfWeek.monday,
      availableGestures: AvailableGestures.horizontalSwipe,
      availableCalendarFormats: const {CalendarFormat.month: ''},
      calendarStyle: CalendarStyle(outsideDaysVisible: false),
      headerVisible: true,
      onVisibleDaysChanged: (first, last, format) {
        _statisticsBloc.add(
          StatisticsEvents.getPillsInCalendar(
              first.millisecondsSinceEpoch ~/ 1000,
              last.millisecondsSinceEpoch ~/ 1000),
        );
      },
      headerStyle: _buildHeaderStyle(context),
      daysOfWeekStyle: _daysOfWeekStyle(),
      rowHeight: 50.h,
      builders: CalendarBuilders(
        dowWeekdayBuilder: _dowWeekdayBuilder,
        dayBuilder: _dayBuilder,
        markersBuilder: (_, date, events, holidays) {
          return isLoading
              ? [
                  Positioned(
                    bottom: 2,
                    child: _progressBar(),
                  ),
                ]
              : _markersBuilder(_, date, events, holidays);
        },
      ),
      onDaySelected: (date, events, holidays) =>
          _onDaySelected(date, events, holidays),
    );

But in the update, most of these properties are removed therefore almost all the properties are throwing errors(calendarController, events, initialCalendarFormat, formatAnimation, onVisibleDaysChanged, builders, dowWeekdayBuilder, dayBuilder, markersBuilder, onDaySelected) with the upgraded version and I can't seem to figure out what to replace them with. Any help would be great, thanks!

@aleksanderwozniak
Copy link
Owner

Check out the pinned issue (#434) for details on this. You will find additional info in README and examples.

@sarohabhawna
Copy link
Author

Hi @aleksanderwozniak, thank you for sharing the link. I've tried to follow that and have changed the Widget but now the calendar is not rendering at all. Not sure what I've missed here.

TableCalendar(
      firstDay: DateTime(DateTime.now().year - 1),
      lastDay: DateTime(DateTime.now().year + 1),
      focusedDay: DateTime.now(),
      eventLoader: _getEventsFromDay,
      calendarFormat: CalendarFormat.month,
      startingDayOfWeek: StartingDayOfWeek.monday,
      availableGestures: AvailableGestures.horizontalSwipe,
      availableCalendarFormats: const {CalendarFormat.month: ''},
      calendarStyle: CalendarStyle(outsideDaysVisible: false),
      headerVisible: true,
      onRangeSelected: (first, last, format) {
        _statisticsBloc.add(
          StatisticsEvents.getPillsInCalendar(
              first!.millisecondsSinceEpoch ~/ 1000,
              last!.millisecondsSinceEpoch ~/ 1000),
        );
      },
      headerStyle: _buildHeaderStyle(context),
      daysOfWeekStyle: _daysOfWeekStyle(),
      rowHeight: 50.h,
      calendarBuilders: CalendarBuilders(
        dowBuilder: _dowWeekdayBuilder,
        defaultBuilder: _dayBuilder,
        todayBuilder: _dayBuilder,
        markerBuilder: (context, date, events) {
          return isLoading
              ? Positioned(
                  bottom: 2,
                  child: _progressBar(),
                )
              : _markersBuilder(context, date, events);
        },
      ),
      onDaySelected: (date, events) => _onDaySelected(date, events),
    );

@aleksanderwozniak
Copy link
Owner

Which errors are you getting with the code above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants