From e8e5ea2afd9904e3d99d21b0af16af9fddfbcbbc Mon Sep 17 00:00:00 2001 From: apoleon33 Date: Fri, 29 Dec 2023 14:47:45 +0100 Subject: [PATCH] albums generated day by day --- lib/main.dart | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 09a4df9..d68f36f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -67,6 +67,21 @@ class _MyHomePageState extends State { // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. + DateTime timeNow = DateTime.now(); + List albumCards = [ + const SizedBox(height: 16), + AlbumCard(time: timeNow), + ]; + DateTime deadline = DateTime.parse('2023-12-25'); + DateTime date = timeNow; + + while (date.isAfter(deadline)) { + date = DateTime(date.year, date.month, date.day - 1); + albumCards.add(const SizedBox(height: 13)); + albumCards.add(AlbumCard(time: date)); + + } + return Scaffold( appBar: AppBar( leading: IconButton( @@ -105,18 +120,7 @@ class _MyHomePageState extends State { // wireframe for each widget. mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox(height: 16), - AlbumCard(time: DateTime.now()), - SizedBox(height: 16), - AlbumCard(time: DateTime.parse("2023-12-27")), - SizedBox(height: 16), - AlbumCard(time: DateTime.parse("2023-12-26")), - SizedBox(height: 16), - AlbumCard(time: DateTime.parse("2023-11-27")), - SizedBox(height: 16), - AlbumCard(time: DateTime.parse("2023-12-25")) - ], + children: albumCards, ), ), ),