SfCalendar constructor

SfCalendar(
  1. {Key? key,
  2. CalendarView view = CalendarView.day,
  3. int firstDayOfWeek = 7,
  4. double headerHeight = 40,
  5. double viewHeaderHeight = -1,
  6. Color? todayHighlightColor,
  7. TextStyle? todayTextStyle,
  8. Color? cellBorderColor,
  9. Color? backgroundColor,
  10. CalendarDataSource<Object?>? dataSource,
  11. String? timeZone,
  12. Decoration? selectionDecoration,
  13. ViewChangedCallback? onViewChanged,
  14. CalendarTapCallback? onTap,
  15. CalendarLongPressCallback? onLongPress,
  16. CalendarSelectionChangedCallback? onSelectionChanged,
  17. CalendarController? controller,
  18. String? appointmentTimeTextFormat,
  19. List<DateTime>? blackoutDates,
  20. ScheduleViewMonthHeaderBuilder? scheduleViewMonthHeaderBuilder,
  21. MonthCellBuilder? monthCellBuilder,
  22. CalendarAppointmentBuilder? appointmentBuilder,
  23. TimeRegionBuilder? timeRegionBuilder,
  24. String? headerDateFormat,
  25. CalendarHeaderStyle headerStyle = const CalendarHeaderStyle(),
  26. ViewHeaderStyle viewHeaderStyle = const ViewHeaderStyle(),
  27. TimeSlotViewSettings timeSlotViewSettings = const TimeSlotViewSettings(),
  28. ResourceViewSettings resourceViewSettings = const ResourceViewSettings(),
  29. MonthViewSettings monthViewSettings = const MonthViewSettings(),
  30. DateTime? initialDisplayDate,
  31. DateTime? initialSelectedDate,
  32. ScheduleViewSettings scheduleViewSettings = const ScheduleViewSettings(),
  33. DateTime? minDate,
  34. DateTime? maxDate,
  35. TextStyle appointmentTextStyle = const TextStyle(color: Colors.white, fontSize: -1, fontWeight: FontWeight.w500),
  36. bool showNavigationArrow = false,
  37. bool showDatePickerButton = false,
  38. bool showTodayButton = false,
  39. bool allowViewNavigation = false,
  40. bool showCurrentTimeIndicator = true,
  41. double cellEndPadding = -1,
  42. ViewNavigationMode viewNavigationMode = ViewNavigationMode.snap,
  43. List<CalendarView>? allowedViews,
  44. List<TimeRegion>? specialRegions,
  45. LoadMoreWidgetBuilder? loadMoreWidgetBuilder,
  46. TextStyle? blackoutDatesTextStyle,
  47. bool showWeekNumber = false,
  48. WeekNumberStyle weekNumberStyle = const WeekNumberStyle(),
  49. ResourceViewHeaderBuilder? resourceViewHeaderBuilder,
  50. bool allowAppointmentResize = false,
  51. AppointmentResizeStartCallback? onAppointmentResizeStart,
  52. AppointmentResizeUpdateCallback? onAppointmentResizeUpdate,
  53. AppointmentResizeEndCallback? onAppointmentResizeEnd,
  54. bool allowDragAndDrop = false,
  55. DragAndDropSettings dragAndDropSettings = const DragAndDropSettings(),
  56. AppointmentDragStartCallback? onDragStart,
  57. AppointmentDragUpdateCallback? onDragUpdate,
  58. AppointmentDragEndCallback? onDragEnd}
)

Creates a SfCalendar widget, which used to scheduling and managing events.

By default it displays CalendarView.day view with current date visible.

To navigate to different views set view property with a desired CalendarView.

Use DataSource property to set the appointments to the scheduler.

Implementation

SfCalendar({
  Key? key,
  this.view = CalendarView.day,
  this.firstDayOfWeek = 7,
  this.headerHeight = 40,
  this.viewHeaderHeight = -1,
  this.todayHighlightColor,
  this.todayTextStyle,
  this.cellBorderColor,
  this.backgroundColor,
  this.dataSource,
  this.timeZone,
  this.selectionDecoration,
  this.onViewChanged,
  this.onTap,
  this.onLongPress,
  this.onSelectionChanged,
  this.controller,
  this.appointmentTimeTextFormat,
  this.blackoutDates,
  this.scheduleViewMonthHeaderBuilder,
  this.monthCellBuilder,
  this.appointmentBuilder,
  this.timeRegionBuilder,
  this.headerDateFormat,
  this.headerStyle = const CalendarHeaderStyle(),
  this.viewHeaderStyle = const ViewHeaderStyle(),
  this.timeSlotViewSettings = const TimeSlotViewSettings(),
  this.resourceViewSettings = const ResourceViewSettings(),
  this.monthViewSettings = const MonthViewSettings(),
  DateTime? initialDisplayDate,
  this.initialSelectedDate,
  this.scheduleViewSettings = const ScheduleViewSettings(),
  DateTime? minDate,
  DateTime? maxDate,
  this.appointmentTextStyle = const TextStyle(
      color: Colors.white, fontSize: -1, fontWeight: FontWeight.w500),
  this.showNavigationArrow = false,
  this.showDatePickerButton = false,
  this.showTodayButton = false,
  this.allowViewNavigation = false,
  this.showCurrentTimeIndicator = true,
  this.cellEndPadding = -1,
  this.viewNavigationMode = ViewNavigationMode.snap,
  this.allowedViews,
  this.specialRegions,
  this.loadMoreWidgetBuilder,
  this.blackoutDatesTextStyle,
  this.showWeekNumber = false,
  this.weekNumberStyle = const WeekNumberStyle(),
  this.resourceViewHeaderBuilder,
  this.allowAppointmentResize = false,
  this.onAppointmentResizeStart,
  this.onAppointmentResizeUpdate,
  this.onAppointmentResizeEnd,
  this.allowDragAndDrop = false,
  this.dragAndDropSettings = const DragAndDropSettings(),
  this.onDragStart,
  this.onDragUpdate,
  this.onDragEnd,
})  : assert(firstDayOfWeek >= 1 && firstDayOfWeek <= 7),
      assert(headerHeight >= 0),
      assert(viewHeaderHeight >= -1),
      assert(minDate == null || maxDate == null || minDate.isBefore(maxDate)),
      assert(minDate == null || maxDate == null || maxDate.isAfter(minDate)),
      assert(cellEndPadding >= -1),
      initialDisplayDate = initialDisplayDate ??
          DateTime(DateTime.now().year, DateTime.now().month,
              DateTime.now().day, 08, 45),
      minDate = minDate ?? DateTime(01),
      maxDate = maxDate ?? DateTime(9999, 12, 31),
      super(key: key);