Flutter 热力图日历
基于 GitHub 贡献图的热图日历,可用于可视化随时间变化的值。
![]()
安装
1. 依赖它
将此添加到您的 package 的 pubspec.yaml 文件中
dependencies:
heatmap_calendar: ^1.2.5
2. 安装它
您可以从命令行安装包
通过 pub
$ pub get
使用 Flutter
$ flutter pub get
示例
import 'package:heatmap_calendar/heatmap_calendar.dart';
import 'package:heatmap_calendar/time_utils.dart';
...
HeatMapCalendar(
input: {
TimeUtils.removeTime(DateTime.now().subtract(Duration(days: 3))): 5,
TimeUtils.removeTime(DateTime.now().subtract(Duration(days: 2))): 35,
TimeUtils.removeTime(DateTime.now().subtract(Duration(days: 1))): 14,
TimeUtils.removeTime(DateTime.now()): 5,
},
colorThresholds: {
1: Colors.green[100],
10: Colors.green[300],
30: Colors.green[500]
},
weekDaysLabels: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
monthsLabels: [
"",
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
],
squareSize: 16.0,
textOpacity: 0.3,
labelTextColor: Colors.blueGrey,
dayTextColor: Colors.blue[500],
)