Articles in this section
Category / Section

How to highlight the weekends in the Flutter Calendar?

1 min read

In the Flutter Event Calendar, you can highlight the time slots for weekends using the ‘specialRegions’ property of Calendar.

STEP 1: Add the time region for weekends using the ‘startTime’, ’endTime’ properties of the `TimeRegion`. Using recurrence rule property of the time region to repeat the time regions with all the weekends after the start time date.


List<TimeRegion> _getTimeRegions() {
  final List<TimeRegion> regions = <TimeRegion>[];
  regions.add(TimeRegion(
      startTime: DateTime(2020, 5, 29, 00, 0, 0),
      endTime: DateTime(2020, 5, 29, 24, 0, 0),
      recurrenceRule: 'FREQ=WEEKLY;INTERVAL=1;BYDAY=SAT,SUN',
      color: Color(0xffbD3D3D3),
   ));
 
  return regions;
}

STEP 2: Call the _getTimeRegions() method to customize the specified time slot of the SfCalendar. Please find the code snippet for the same.

body: SafeArea(
  child: SfCalendar(
    view: CalendarView.week,
    dataSource: getCalendarDataSource(),
    specialRegions: _getTimeRegions(),
  ),
),

Highlighted timeslots touch interaction can be enabled or disabled.

Reference blog: https://www.syncfusion.com/blogs/post/introducing-a-special-time-region-in-the-flutter-event-calendar.aspx

View sample in GitHub


Flutter calendar weekend highlight

 

Conclusion

I hope you enjoyed learning about how to highlight the weekends in the Flutter Calendar.

You can refer to our Flutter Calendar feature tour page to learn about its other groundbreaking feature representations. You can explore our documentation to understand how to present and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other components.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!



Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied