monthCellStyle property Null safety

MonthCellStyle monthCellStyle
final

Sets the style to customize SfCalendar month cells.

Allows to customize the MonthCellStyle.textStyle, MonthCellStyle.trailingDatesTextStyle, MonthCellStyle.leadingDatesTextStyle, MonthCellStyle.backgroundColor, MonthCellStyle.todayBackgroundColor, MonthCellStyle.leadingDatesBackgroundColor and MonthCellStyle.trailingDatesBackgroundColor in month cells of month view in calendar.

Defaults to null.

See more:

Widget build(BuildContext context) {
   return Container(
     child: SfCalendar(
       view: CalendarView.month,
       dataSource: _getCalendarDataSource(),
       monthViewSettings: MonthViewSettings(
          dayFormat: 'EEE',
          numberOfWeeksInView: 4,
          appointmentDisplayCount: 2,
          appointmentDisplayMode: MonthAppointmentDisplayMode.appointment,
          showAgenda: false,
          navigationDirection: MonthNavigationDirection.horizontal,
          monthCellStyle
               : MonthCellStyle(textStyle: TextStyle(fontStyle: FontStyle.
          normal, fontSize: 15, color: Colors.black),
               trailingDatesTextStyle: TextStyle(
                   fontStyle: FontStyle.normal,
                   fontSize: 15,
                   color: Colors.black),
               leadingDatesTextStyle: TextStyle(
                   fontStyle: FontStyle.normal,
                   fontSize: 15,
                   color: Colors.black),
               backgroundColor: Colors.red,
               todayBackgroundColor: Colors.blue,
               leadingDatesBackgroundColor: Colors.grey,
               trailingDatesBackgroundColor: Colors.grey)),
     ),
   );
 }

class DataSource extends CalendarDataSource {
 DataSource(List<Appointment> source) {
   appointments = source;
 }
}

 DataSource _getCalendarDataSource() {
   List<Appointment> appointments = <Appointment>[];
   appointments.add(Appointment(
     startTime: DateTime.now(),
     endTime: DateTime.now().add(Duration(hours: 2)),
     isAllDay: true,
     subject: 'Meeting',
     color: Colors.blue,
     startTimeZone: '',
     endTimeZone: '',
   ));

   return DataSource(appointments);
 }

Implementation

final MonthCellStyle monthCellStyle;