Created
October 4, 2022 20:53
-
-
Save luscas/b042eba4304eb068af744ced3c754f43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Noticia { | |
String title; | |
DateTime createdAt; | |
Noticia(this.title, this.createdAt); | |
} | |
void main() { | |
List<Noticia> registers = [ | |
Noticia("Primeira postagem", DateTime(2022,07,01)), | |
Noticia("Segunda postagem", DateTime(2022,11,01)), | |
]; | |
Iterable<Noticia> esteAno = registers.where((Noticia item) { | |
return item.createdAt.year == DateTime.now().year; | |
}); | |
Iterable<Noticia> esteMes = registers.where((Noticia item) { | |
return item.createdAt.year == DateTime.now().year && item.createdAt.month == DateTime.now().month; | |
}); | |
print(esteMes.first.title); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment