@@ -349,14 +349,6 @@ class ItemList extends StatefulWidget {
349
349
}
350
350
351
351
class _ItemListState extends State <ItemList > {
352
- late List items;
353
-
354
- @override
355
- void initState () {
356
- super .initState ();
357
- items = widget.items;
358
- }
359
-
360
352
@override
361
353
Widget build (BuildContext context) {
362
354
return LayoutBuilder (builder: (context, constraints) {
@@ -369,8 +361,8 @@ class _ItemListState extends State<ItemList> {
369
361
padding: const EdgeInsets .symmetric (horizontal: 8 , vertical: 0 ),
370
362
scrollDirection: Axis .horizontal,
371
363
itemBuilder: (context, index) {
372
- double width = height * (items[index]? ['aspectRatio' ] ?? 1 );
373
- String ? subtitle = _buildSubtitle (items[index]);
364
+ double width = height * (widget. items[index]? ['aspectRatio' ] ?? 1 );
365
+ String ? subtitle = _buildSubtitle (widget. items[index]);
374
366
return Adaptivecard (
375
367
elevation: 0 ,
376
368
borderRadius: BorderRadius .circular (8 ),
@@ -379,31 +371,33 @@ class _ItemListState extends State<ItemList> {
379
371
child: AdaptiveInkWell (
380
372
padding: EdgeInsets .all (Platform .isWindows ? 12 : 0 ),
381
373
onTap: () async {
382
- if (items[index]['endpoint' ] != null &&
383
- items[index]['videoId' ] == null ) {
374
+ if (widget. items[index]['endpoint' ] != null &&
375
+ widget. items[index]['videoId' ] == null ) {
384
376
Navigator .push (
385
377
context,
386
378
AdaptivePageRoute .create (
387
- (context) =>
388
- BrowseScreen ( endpoint: items[index]['endpoint' ]),
379
+ (context) => BrowseScreen (
380
+ endpoint: widget. items[index]['endpoint' ]),
389
381
));
390
382
} else {
391
383
await GetIt .I <MediaPlayer >()
392
- .playSong (Map .from (items[index]));
384
+ .playSong (Map .from (widget. items[index]));
393
385
}
394
386
},
395
387
onSecondaryTap: () {
396
- if (items[index]['videoId' ] != null ) {
397
- Modals .showSongBottomModal (context, items[index]);
398
- } else if (items[index]['playlistId' ] != null ) {
399
- Modals .showPlaylistBottomModal (context, items[index]);
388
+ if (widget.items[index]['videoId' ] != null ) {
389
+ Modals .showSongBottomModal (context, widget.items[index]);
390
+ } else if (widget.items[index]['playlistId' ] != null ) {
391
+ Modals .showPlaylistBottomModal (
392
+ context, widget.items[index]);
400
393
}
401
394
},
402
395
onLongPress: () {
403
- if (items[index]['videoId' ] != null ) {
404
- Modals .showSongBottomModal (context, items[index]);
405
- } else if (items[index]['playlistId' ] != null ) {
406
- Modals .showPlaylistBottomModal (context, items[index]);
396
+ if (widget.items[index]['videoId' ] != null ) {
397
+ Modals .showSongBottomModal (context, widget.items[index]);
398
+ } else if (widget.items[index]['playlistId' ] != null ) {
399
+ Modals .showPlaylistBottomModal (
400
+ context, widget.items[index]);
407
401
}
408
402
},
409
403
borderRadius: BorderRadius .circular (8 ),
@@ -414,14 +408,14 @@ class _ItemListState extends State<ItemList> {
414
408
height: height,
415
409
decoration: BoxDecoration (
416
410
color: Colors .grey.withOpacity (0.1 ),
417
- borderRadius: items[index]['type' ] == 'ARTIST'
411
+ borderRadius: widget. items[index]['type' ] == 'ARTIST'
418
412
? BorderRadius .circular (height / 2 )
419
413
: BorderRadius .circular (8 ),
420
414
image: DecorationImage (
421
415
fit: BoxFit .cover,
422
416
image: CachedNetworkImageProvider (
423
417
getEnhancedImage (
424
- items[index]['thumbnails' ].first['url' ],
418
+ widget. items[index]['thumbnails' ].first['url' ],
425
419
dp: MediaQuery .of (context).devicePixelRatio,
426
420
width: width),
427
421
),
@@ -438,7 +432,9 @@ class _ItemListState extends State<ItemList> {
438
432
contentPadding: const EdgeInsets .symmetric (
439
433
horizontal: 0 , vertical: 4 ),
440
434
title: Text (
441
- items[index]['title' ].toString ().breakWord,
435
+ widget.items[index]['title' ]
436
+ .toString ()
437
+ .breakWord,
442
438
maxLines: 2 ,
443
439
style: const TextStyle (height: 1.3 ),
444
440
overflow: TextOverflow .ellipsis,
@@ -447,7 +443,7 @@ class _ItemListState extends State<ItemList> {
447
443
subtitle: Row (
448
444
crossAxisAlignment: CrossAxisAlignment .center,
449
445
children: [
450
- if (items[index]['explicit' ] == true )
446
+ if (widget. items[index]['explicit' ] == true )
451
447
Padding (
452
448
padding: const EdgeInsets .only (right: 2 ),
453
449
child: Icon (
@@ -480,7 +476,7 @@ class _ItemListState extends State<ItemList> {
480
476
);
481
477
},
482
478
separatorBuilder: (context, index) => const SizedBox (width: 8 ),
483
- itemCount: items.length,
479
+ itemCount: widget. items.length,
484
480
),
485
481
);
486
482
});
0 commit comments