Flutter Heatmap Calendar

Flutter Heatmap Calendar inspired by github contribution chart.

Flutter Heatmap Calendar provides traditional contribution chart called HeatMap and calendar version of it called HeatMapCalendar.

HeatMap HeatMapCalendar

Getting started

Depend on it.

flutter pub add flutter_heatmap_calendar

or

Add below line to your personal package's pubspec.yaml.

dependencies:
  flutter_heatmap_calendar: ^1.0.5

And run flutter pub get to install.

Import it.

import 'package:flutter_heatmap_calendar/flutter_heatmap_calendar.dart';

Props

HeatMap

PropsTypesDefaultDescription
startDateDateTime?1 year before of the endDateStart date of HeatMap.
endDateDateTime?Today
( DateTime.now() )
Last day of HeatMap.
datasetsMap<DateTime, int>?nullSets of data which to be displayed.
colorsetsMap<int, Color>requiredSets of color values for its thresholds key value.
At least one Color is required.
Be aware that only first color will be used if ColorMode is ColorMode.opacity.
defaultColorColor?#F8F9FA Color(0xFFF8F9FA)Default color of every block.
textColorColor?#8A8A8A Color(0xFF8A8A8A)Color value of every text.
colorModeColorModeColorMode.opacityColorMode.opacity requires just one colorsets value and changes color dynamically based on hightest value of datasets.
ColorMode.color changes colors based on colorsets thresholds key value.
sizedouble?20The size of every block.
fontSizedouble?nullThe size of every text.
onClickFunction(DateTime)?nullCallback function which will be called if user clicks the block.
marginEdgeInsets?EdgeInsets.all(2)The margin value of block.
borderRadiusdouble?5Border radius value of block.
scrollableboolfalseMake HeatMap scrollable if scrollable is true.
showTextbool?falseShow day text in every block if showText is true.
showColorTipbool?trueShow color tip if showColorTip is true.
colorTipHelperList<Widget?>?nullWidgets which are shown at left and right side of colorTip.
First value is the left side widget and second value is the right side widget.
Give null value makes default 'less' and 'more' text.
colorTipCountint?7Length of colorTip block.
colorTipSizedouble?10The size of colorTip.

HeatMapCalendar

PropsTypesDefaultDescription
initDateDateTime?Today
( DateTime.now() )
Initialized Year/Month value of HeatMapCalendar.
datasetsMap<DateTime, int>?nullSets of data which to be displayed.
colorsetsMap<int, Color>requiredSets of color values for its thresholds key value.
At least one Color is required.
Be aware that only first color will be used if ColorMode is ColorMode.opacity.
defaultColorColor?#F8F9FA Color(0xFFF8F9FA)Default color of every block.
textColorColor?#8A8A8A Color(0xFF8A8A8A)Color value of every text.
colorModeColorModeColorMode.opacityColorMode.opacity requires just one colorsets value and changes color dynamically based on hightest value of datasets.
ColorMode.color changes colors based on colorsets thresholds key value.
sizedouble?42The size of every block.
fontSizedouble?nullThe size of every text.
monthFontSizedouble?12The size of month label.
weekFontSizedouble?12The size of week label.
weekTextColorColor?#758EA1 Color(0xFF758EA1)Default color of every block.
onClickFunction(DateTime)?nullCallback function which will be called if user clicks the block.
marginEdgeInsetsEdgeInsets.all(2)The margin value of block.
borderRadiusdouble?5Border radius value of block.
flexiblebool?falseMakes HeatMapCalendar's size dynamically fit on screen.
If flexible is true then, size props will be ignored.
showColorTipbool?trueShow color tip if showColorTip is true.
colorTipHelperList<Widget?>?nullWidgets which are shown at left and right side of colorTip.
First value is the left side widget and second value is the right side widget.
Give null value makes default 'less' and 'more' text.
colorTipCountint?7Length of colorTip block.
colorTipSizedouble?10The size of colorTip.

Example

HeatMap

import 'package:flutter_heatmap_calendar/flutter_heatmap_calendar.dart';
...
HeatMap(
  datasets: {
    DateTime(2021, 1, 6): 3,
    DateTime(2021, 1, 7): 7,
    DateTime(2021, 1, 8): 10,
    DateTime(2021, 1, 9): 13,
    DateTime(2021, 1, 13): 6,
  },
  colorMode: ColorMode.opacity,
  showText: false,
  scrollable: true,
  colorsets: {
    1: Colors.red,
    3: Colors.orange,
    5: Colors.yellow,
    7: Colors.green,
    9: Colors.blue,
    11: Colors.indigo,
    13: Colors.purple,
  },
  onClick: (value) {
    ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(value.toString())));
  },
);

HeatMapCalendar

import 'package:flutter_heatmap_calendar/flutter_heatmap_calendar.dart';
...
HeatMapCalendar(
  defaultColor: Colors.white,
  flexible: true,
  colorMode: ColorMode.color,
  datasets: {
    DateTime(2021, 1, 6): 3,
    DateTime(2021, 1, 7): 7,
    DateTime(2021, 1, 8): 10,
    DateTime(2021, 1, 9): 13,
    DateTime(2021, 1, 13): 6,
  },
  colorsets: const {
    1: Colors.red,
    3: Colors.orange,
    5: Colors.yellow,
    7: Colors.green,
    9: Colors.blue,
    11: Colors.indigo,
    13: Colors.purple,
  },
  onClick: (value) {
    ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(value.toString())));
  },
);

License

MIT License

Copyright (c) 2021 Kim Seung Hwan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Libraries

flutter_heatmap_calendar