diff --git a/lib/screens/home_screen/home_screen.dart b/lib/screens/home_screen/home_screen.dart index 6ae2f2b..5148a09 100644 --- a/lib/screens/home_screen/home_screen.dart +++ b/lib/screens/home_screen/home_screen.dart @@ -51,7 +51,6 @@ class _HomeScreenState extends State { nextLoading = false; }); Map home = await ytMusic.browse(); - // pprint(home); if (mounted) { setState(() { initialLoading = false; @@ -61,8 +60,6 @@ class _HomeScreenState extends State { continuation = home['continuation']; }); } - // pprint(home['sections'][1]['contents']); - // await fetchNext(); } refresh() async { diff --git a/lib/screens/home_screen/section_item.dart b/lib/screens/home_screen/section_item.dart index 609435b..7979a7f 100644 --- a/lib/screens/home_screen/section_item.dart +++ b/lib/screens/home_screen/section_item.dart @@ -349,14 +349,6 @@ class ItemList extends StatefulWidget { } class _ItemListState extends State { - late List items; - - @override - void initState() { - super.initState(); - items = widget.items; - } - @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, constraints) { @@ -369,8 +361,8 @@ class _ItemListState extends State { padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 0), scrollDirection: Axis.horizontal, itemBuilder: (context, index) { - double width = height * (items[index]?['aspectRatio'] ?? 1); - String? subtitle = _buildSubtitle(items[index]); + double width = height * (widget.items[index]?['aspectRatio'] ?? 1); + String? subtitle = _buildSubtitle(widget.items[index]); return Adaptivecard( elevation: 0, borderRadius: BorderRadius.circular(8), @@ -379,31 +371,33 @@ class _ItemListState extends State { child: AdaptiveInkWell( padding: EdgeInsets.all(Platform.isWindows ? 12 : 0), onTap: () async { - if (items[index]['endpoint'] != null && - items[index]['videoId'] == null) { + if (widget.items[index]['endpoint'] != null && + widget.items[index]['videoId'] == null) { Navigator.push( context, AdaptivePageRoute.create( - (context) => - BrowseScreen(endpoint: items[index]['endpoint']), + (context) => BrowseScreen( + endpoint: widget.items[index]['endpoint']), )); } else { await GetIt.I() - .playSong(Map.from(items[index])); + .playSong(Map.from(widget.items[index])); } }, onSecondaryTap: () { - if (items[index]['videoId'] != null) { - Modals.showSongBottomModal(context, items[index]); - } else if (items[index]['playlistId'] != null) { - Modals.showPlaylistBottomModal(context, items[index]); + if (widget.items[index]['videoId'] != null) { + Modals.showSongBottomModal(context, widget.items[index]); + } else if (widget.items[index]['playlistId'] != null) { + Modals.showPlaylistBottomModal( + context, widget.items[index]); } }, onLongPress: () { - if (items[index]['videoId'] != null) { - Modals.showSongBottomModal(context, items[index]); - } else if (items[index]['playlistId'] != null) { - Modals.showPlaylistBottomModal(context, items[index]); + if (widget.items[index]['videoId'] != null) { + Modals.showSongBottomModal(context, widget.items[index]); + } else if (widget.items[index]['playlistId'] != null) { + Modals.showPlaylistBottomModal( + context, widget.items[index]); } }, borderRadius: BorderRadius.circular(8), @@ -414,14 +408,14 @@ class _ItemListState extends State { height: height, decoration: BoxDecoration( color: Colors.grey.withOpacity(0.1), - borderRadius: items[index]['type'] == 'ARTIST' + borderRadius: widget.items[index]['type'] == 'ARTIST' ? BorderRadius.circular(height / 2) : BorderRadius.circular(8), image: DecorationImage( fit: BoxFit.cover, image: CachedNetworkImageProvider( getEnhancedImage( - items[index]['thumbnails'].first['url'], + widget.items[index]['thumbnails'].first['url'], dp: MediaQuery.of(context).devicePixelRatio, width: width), ), @@ -438,7 +432,9 @@ class _ItemListState extends State { contentPadding: const EdgeInsets.symmetric( horizontal: 0, vertical: 4), title: Text( - items[index]['title'].toString().breakWord, + widget.items[index]['title'] + .toString() + .breakWord, maxLines: 2, style: const TextStyle(height: 1.3), overflow: TextOverflow.ellipsis, @@ -447,7 +443,7 @@ class _ItemListState extends State { subtitle: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ - if (items[index]['explicit'] == true) + if (widget.items[index]['explicit'] == true) Padding( padding: const EdgeInsets.only(right: 2), child: Icon( @@ -480,7 +476,7 @@ class _ItemListState extends State { ); }, separatorBuilder: (context, index) => const SizedBox(width: 8), - itemCount: items.length, + itemCount: widget.items.length, ), ); });