Closed develogo closed 2 years ago
This is how I have done it. You can get an idea from this...
groupBy: (e) =>DateFormat('yyyy-MM-dd').format( tz.TZDateTime.from(e.reminderDate, tz.local), )
groupHeaderBuilder: (e) =>Text( checkDate( e.reminderDate.toString(), ), textAlign: TextAlign.start, style: TextStyle( fontSize: 15, color: Colors.blueGrey[300], fontWeight: FontWeight.bold), ), ,
// and the function checkDate
`String checkDate(String dateString) {
tz.TZDateTime checkedTime = tz.TZDateTime.parse(tz.local, dateString);
tz.TZDateTime currentTime = tz.TZDateTime.now(tz.local);
if ((currentTime.year == checkedTime.year) &&
(currentTime.month == checkedTime.month) &&
(currentTime.day == checkedTime.day)) {
return "TODAY";
} else if ((currentTime.year == checkedTime.year) &&
(currentTime.month == checkedTime.month)) {
if ((currentTime.day - checkedTime.day) == 1) {
return "YESTERDAY";
} else if ((currentTime.day - checkedTime.day) == -1) {
return "TOMORROW";
} else {
return DateFormat.yMMMd()
.format(tz.TZDateTime.parse(tz.local, dateString));
}
}
return DateFormat.yMMMd().format(tz.TZDateTime.parse(tz.local, dateString));
}`
Seems to be solved
Look, how can I create 3 groups today, yesterday and the rest of the month?
Im using: groupBy: (ProcedureEntity element) => DateFormat('d') .format(DateTime.parse(element.createdAt)),