本文主要介绍了Flutter仿钉钉考勤日历的示例代码,分享给大家,具体如下:
效果
原型
开发
1. 使用
// 考勤日历
DatePickerDialog(
initialDate: DateTime.now(),
firstDate: DateTime(2020),
lastDate: DateTime(2030),
onDateChanged: onDateChanged,
// 0:无状态,1:正常考勤 2:异常考情,迟到,早退,
// 若不满一个月,日历会自动用0补满一个月
checking: [
0,
0,
1,
2,
],
),
DatePickerDialog是在存在与Flutter的material包中,Flutter自带的日历是以dialog形式存在的,本文将dialog改成StatefulWidget直接在页面中,将多余东西去掉,直接在material/calendar_date_picker.dart中_DayPicker上进行修改。
2. 修改日历中日期样式:
Widget dayWidget = Container(
margin: EdgeInsets.all(4.0),
decoration: decoration,
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(localizations.formatDecimal(day),
style: TextStyle(
fontSize: 14.0,
color: dayColor,
fontWeight: FontWei