Skip to content

Commit

Permalink
cleaner way of creating cards on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
apoleon33 committed Jan 3, 2024
1 parent 204068b commit cb53848
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/albumCard/albumCard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ class AlbumCard extends StatefulWidget {
late DateTime date;
bool isCard;

AlbumCard({super.key, required DateTime time, required this.isCard}) {
date = time;
}
AlbumCard({super.key, required this.date, required this.isCard});

@override
State<AlbumCard> createState() => _AlbumCardState(time: date);
State<AlbumCard> createState() => _AlbumCardState();
}

class _AlbumCardState extends State<AlbumCard> {
Expand All @@ -24,10 +22,13 @@ class _AlbumCardState extends State<AlbumCard> {
String genre = "genre";
double averageRating = 5.0;

_AlbumCardState({required DateTime time}) {
date = time;

_getAlbumByDate();
@override
void initState() {
super.initState();
date = widget.date;
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
_getAlbumByDate();
});
}

void _getAlbumByDate() async {
Expand Down

0 comments on commit cb53848

Please sign in to comment.