Easy Ways to Build a Heat Map Calendar Using the Flutter Event Calendar
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (180).NET Core  (28).NET MAUI  (225)Angular  (113)ASP.NET  (49)ASP.NET Core  (81)ASP.NET MVC  (87)Azure  (41)Black Friday Deal  (1)Blazor  (234)BoldSign  (14)DocIO  (24)Essential JS 2  (110)Essential Studio  (199)File Formats  (72)Flutter  (136)JavaScript  (226)Microsoft  (121)PDF  (83)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (962)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (46)Webinar  (53)Windows Forms  (59)WinUI  (72)WPF  (163)Xamarin  (159)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (10)Business intelligence  (55)Button  (4)C#  (163)Chart  (145)Chart of the week  (57)Cloud  (15)Company  (440)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (73)Development  (677)Doc  (7)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (13)Excel  (43)Extensions  (23)File Manager  (7)Gantt  (21)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (521)Mobile MVC  (9)OLAP server  (2)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (45)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (8)Reporting / Back Office  (9)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (5)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (32)Solution Services  (4)Spreadsheet  (11)SQL  (15)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (113)UI  (403)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (625)What's new  (339)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Easy Ways to Build a Heat Map Calendar Using the Flutter Event Calendar

Easy Ways to Build a Heat Map Calendar Using the Flutter Event Calendar

In this blog post, we are going to discuss how to design a heat map calendar and apply color for the different month cells based on a user’s mobile usage using the Flutter event Calendar widget.

A heat map is a data visualization technique that uses colors the way a bar graph uses height and width. To create a heat map calendar, we require data for a month’s dates. In our example, we are going to display the digital well-being data of a smartphone.

These days, smartphones have become essential, and our daily usage of smartphones is increasingly high. We are using mobile phones for 8 to 9 hours a day. So, to track a user’s mobile phone usage, we can use digital well-being data. The Syncfusion Flutter event Calendar, with its rich feature set, allows users to design a heatmap calendar using custom builder support.

Heat Map Using Flutter Event Calendar
Heat Map Using Flutter Event Calendar

Note: If you are new to the Calendar widget, please go through the Getting started with Flutter event Calendar documentation before proceeding.

Handling data

First, get the required data (mobile usage in hours) and color to render. Then, render the background color to the corresponding UI. For demo purposes, we are providing some random data.

Refer to the following code example.

final List<int> _usageHours = <int>[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,  22, 23];
  final List<HeatMapData> _heatMapDataCollection = <HeatMapData>[];
  final Random random = Random();

  void initState() {

  void _addHeatMapData() {
    for (int i = 0; i < 100; i++) {
      final int hour = random.nextInt(_usageHours.length);
      final Color color = _getMonthCellBackgroundColor(hour);
      _heatMapDataCollection.add(HeatMapData(hour, color));

  Color _getMonthCellBackgroundColor(int hour) {
    if(hour < 6){
      return _kLightGrey;
    }else if(hour < 11){
      return _kLightGreen;
    }else if(hour < 16){
      return _kMidGreen;
    }else if(hour < 21){
      return _kDarkGreen;

    return _kDarkerGreen;

Designing the heat map calendar

In the Flutter event calendar, you can customize the presentation of data and its interaction using the builder support. Customize the calendar month cell to apply the background color related to the corresponding data in each cell using the monthCellBuilder property. Then, assign the data values to the corresponding UI.

Now, return the designed custom UI with the data in the monthCellBuilder callback.

Refer to the following code example.

/// Returns the calendar widget based on the properties passed.
  SfCalendar _getHeatMapCalendar(bool isMobilePlatform) {
    return SfCalendar(
        showNavigationArrow: !isMobilePlatform,
        view: CalendarView.month,
        monthCellBuilder: _monthCellBuilder,
        showDatePickerButton: true,
        maxDate: _maxDate,
        initialDisplayDate: DateTime.now().subtract(Duration(days: 100)),
        monthViewSettings: const MonthViewSettings(
          showTrailingAndLeadingDates: false,

  /// Returns the cell  text color based on the cell background color.
  Color _getCellTextColor(Color backgroundColor) {
    if (backgroundColor == _kDarkGreen || backgroundColor == _kDarkerGreen) {
      return Colors.white;

    return Colors.black;

  /// Returns the builder for month cell.
  Widget _monthCellBuilder(
      BuildContext buildContext, MonthCellDetails details) {
     Color backgroundColor = _heatMapDataCollection[random.nextInt(100)].color;
       backgroundColor = Colors.transparent;
     }else if(isSameDate(details.date, _maxDate)){
       backgroundColor = _getMonthCellBackgroundColor(random.nextInt(_maxDate.hour));
    final Color defaultColor = Colors.white;
    return Container(
      decoration: BoxDecoration(
          color: backgroundColor,
          border: Border.all(color: defaultColor, width: 0.5)),
      child: Center(
        child: Text(
          style: TextStyle(color: _getCellTextColor(backgroundColor)),

Now, the Calendar widget is completely configured. Run the sample to see the event calendar with heat map data.

Heat Map Calendar Using Flutter Event Calendar
Heat Map Calendar Using Flutter Event Calendar


For more information, refer to designing a heat map using the Flutter event Calendar demo.


Thanks for reading! In this blog post, we’ve seen how to design a heatmap calendar using the Flutter event Calendar. This widget is available in AndroidiOSwebWindowsMac, and Linux platforms. With this heat map data visualization, you can easily understand the trends in data with different color patterns!

Also, you can check out our other Flutter project demos in this GitHub repository. Feel free to try out these demos and share your feedback or questions in the comments section.

Our Calendar component is also available in our Blazor, ASP.NET (CoreMVC), JavaScriptAngularReactVueXamarinUWPWinFormsWPF, and WinUI platforms. Use them to build astonishing applications!

For existing customers, the new version is available for download from the License and Downloads page. If you are not yet a Syncfusion customer, you can try our 30-day free trial to check out our available features.

You can contact us through our support forumDirect-Trac, or feedback portal. We are always happy to assist you!

Related blogs


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed