I want to have a list when the date of each list item is equal to todays date. I, personally, wrote this code in listview.builder in future builder:
itemBuilder: (context, index) {
var now = DateTime.now();
var nowFormated = DateFormat.MMMd().format(now);
DateTime time = DateTime.parse(snapshot.data[index].date);
var databaseFormated = DateFormat.MMMd().add_Hm().format(time);
var checkerFormated = DateFormat.MMMd().format(time);
if (checkerFormated == nowFormated) {
print (checkerFormated);
print(nowFormated);
return Todays(
snapshot.data[index].name != null
? snapshot.data[index].name
: '',
databaseFormated);
} else {
return null;
}
}
this code only works for the first item. it doesn't show any further items.