From a5233a33da1a2611c53901b9a56bc8b66884d4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Mon, 27 May 2024 21:46:18 +0200 Subject: [PATCH] fix: remove FastCachedImage #1 --- lib/api/audio/audioplayer_service.dart | 4 +- lib/main.dart | 7 ---- lib/views/album_view.dart | 1 + lib/widgets/hero_banner.dart | 12 +++--- lib/widgets/image_cover.dart | 10 ++--- lib/widgets/player.dart | 19 ++++----- lib/widgets/song_row.dart | 12 ++++-- pubspec.lock | 56 +++++++++++++++----------- pubspec.yaml | 2 +- 9 files changed, 65 insertions(+), 58 deletions(-) diff --git a/lib/api/audio/audioplayer_service.dart b/lib/api/audio/audioplayer_service.dart index b51f213..3cd21bb 100644 --- a/lib/api/audio/audioplayer_service.dart +++ b/lib/api/audio/audioplayer_service.dart @@ -1,4 +1,4 @@ -import 'package:fast_cached_network_image/fast_cached_network_image.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:just_audio/just_audio.dart'; import 'package:just_audio_background/just_audio_background.dart'; @@ -56,7 +56,7 @@ class AudioPlayerService { themeNotifier.value = ColorScheme.fromSeed(seedColor: Colors.deepPurple); } themeNotifier.value = await ColorScheme.fromImageProvider( - provider: FastCachedImageProvider( + provider: CachedNetworkImageProvider( AudioPlayerService().song!.coverArtUrl, ), ); diff --git a/lib/main.dart b/lib/main.dart index 22bd0fe..4ee5e23 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,11 +1,9 @@ -import 'package:fast_cached_network_image/fast_cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:just_audio_background/just_audio_background.dart'; import 'package:just_audio_media_kit/just_audio_media_kit.dart'; import 'package:ocarina/api/subsonic/song.dart'; import 'package:ocarina/views/home_view.dart'; import 'package:ocarina/widgets/player.dart'; -import 'package:path_provider/path_provider.dart'; import 'package:responsive_sizer/responsive_sizer.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -19,11 +17,6 @@ void main() async { androidNotificationOngoing: true, ); - await FastCachedImageConfig.init( - clearCacheAfter: const Duration(days: 31), - subDir: (await getApplicationCacheDirectory()).path, - ); - sp = await SharedPreferences.getInstance(); runApp(const MyApp()); } diff --git a/lib/views/album_view.dart b/lib/views/album_view.dart index ed0de3c..489bc9c 100644 --- a/lib/views/album_view.dart +++ b/lib/views/album_view.dart @@ -49,6 +49,7 @@ class _AlbumViewState extends State { ), SizedBox( height: 65.h, + width: 95.w, child: ListView.builder( itemBuilder: (c, i) => InkWell( onTap: () async { diff --git a/lib/widgets/hero_banner.dart b/lib/widgets/hero_banner.dart index e7da08e..22579b0 100644 --- a/lib/widgets/hero_banner.dart +++ b/lib/widgets/hero_banner.dart @@ -1,4 +1,4 @@ -import 'package:fast_cached_network_image/fast_cached_network_image.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:responsive_sizer/responsive_sizer.dart'; import 'package:shimmer/shimmer.dart'; @@ -27,16 +27,16 @@ class HeroBanner extends StatelessWidget { width: 180, child: Hero( tag: heroTag, - child: FastCachedImage( - url: imageUrl, - loadingBuilder: (c, d) => Shimmer.fromColors( + child: CachedNetworkImage( + imageUrl: imageUrl, + placeholder: (c, d) => Shimmer.fromColors( baseColor: Colors.grey.shade300, highlightColor: Colors.grey.shade100, child: Container( color: Colors.grey, ), ), - errorBuilder: (c, _, __) { + errorWidget: (c, _, __) { return ColoredBox( color: Theme.of(context).colorScheme.primaryContainer, child: Center( @@ -62,7 +62,7 @@ class HeroBanner extends StatelessWidget { ), Text(description), ], - ) + ), ], ), ); diff --git a/lib/widgets/image_cover.dart b/lib/widgets/image_cover.dart index 87199c1..0d9694e 100644 --- a/lib/widgets/image_cover.dart +++ b/lib/widgets/image_cover.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:fast_cached_network_image/fast_cached_network_image.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; import 'package:text_scroll/text_scroll.dart'; @@ -27,16 +27,16 @@ class ImageCover extends StatelessWidget { tag: heroTag, child: ClipRRect( borderRadius: BorderRadius.circular(8), - child: FastCachedImage( - url: imageUrl, - loadingBuilder: (c, d) => Shimmer.fromColors( + child: CachedNetworkImage( + imageUrl: imageUrl, + placeholder: (c, d) => Shimmer.fromColors( baseColor: Colors.grey.shade300, highlightColor: Colors.grey.shade100, child: Container( color: Colors.grey, ), ), - errorBuilder: (c, _, __) { + errorWidget: (c, _, __) { return ColoredBox( color: Theme.of(context).colorScheme.primaryContainer, child: Center( diff --git a/lib/widgets/player.dart b/lib/widgets/player.dart index ab2887a..ebc5acd 100644 --- a/lib/widgets/player.dart +++ b/lib/widgets/player.dart @@ -1,8 +1,8 @@ import 'dart:convert'; import 'package:auto_size_text/auto_size_text.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:crypto/crypto.dart'; -import 'package:fast_cached_network_image/fast_cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:ocarina/api/audio/audioplayer_service.dart'; import 'package:ocarina/api/subsonic/song.dart'; @@ -100,7 +100,7 @@ class PlayerState extends State { ), ), ) - : FastCachedImage( + : CachedNetworkImage( key: Key( md5 .convert( @@ -110,8 +110,8 @@ class PlayerState extends State { ) .toString(), ), - url: t.coverArtUrl, - loadingBuilder: (c, d) => + imageUrl: t.coverArtUrl, + placeholder: (c, d) => Shimmer.fromColors( baseColor: Colors.grey.shade300, highlightColor: @@ -120,7 +120,7 @@ class PlayerState extends State { color: Colors.grey, ), ), - errorBuilder: (c, _, __) { + errorWidget: (c, _, __) { logger ..e(_) ..e(__); @@ -226,16 +226,17 @@ class PlayerState extends State { ), ), ) - : (FastCachedImage( - url: AudioPlayerService().song!.coverArtUrl, - loadingBuilder: (c, d) => Shimmer.fromColors( + : (CachedNetworkImage( + imageUrl: + AudioPlayerService().song!.coverArtUrl, + placeholder: (c, d) => Shimmer.fromColors( baseColor: Colors.grey.shade300, highlightColor: Colors.grey.shade100, child: Container( color: Colors.grey, ), ), - errorBuilder: (c, _, __) { + errorWidget: (c, _, __) { logger ..e(_) ..e(__); diff --git a/lib/widgets/song_row.dart b/lib/widgets/song_row.dart index cf46271..e536c9b 100644 --- a/lib/widgets/song_row.dart +++ b/lib/widgets/song_row.dart @@ -1,5 +1,5 @@ import 'package:auto_size_text/auto_size_text.dart'; -import 'package:fast_cached_network_image/fast_cached_network_image.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:text_scroll/text_scroll.dart'; @@ -13,9 +13,13 @@ class SongRow extends StatelessWidget { borderRadius: BorderRadius.circular(8), child: InkWell( child: ListTile( - leading: ClipRRect( - borderRadius: BorderRadius.circular(8), - child: FastCachedImage(url: imageUrl), + leading: SizedBox( + width: 100, + height: 100, + child: ClipRRect( + borderRadius: BorderRadius.circular(8), + child: CachedNetworkImage(imageUrl: imageUrl), + ), ), title: AutoSizeText( songTitle, diff --git a/pubspec.lock b/pubspec.lock index 122eacd..622ca68 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -153,6 +153,30 @@ packages: url: "https://pub.dev" source: hosted version: "8.9.2" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + sha256: "28ea9690a8207179c319965c13cd8df184d5ee721ae2ce60f398ced1219cea1f" + url: "https://pub.dev" + source: hosted + version: "3.3.1" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + sha256: "9e90e78ae72caa874a323d78fa6301b3fb8fa7ea76a8f96dc5b5bf79f283bf2f" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + sha256: "205d6a9f1862de34b93184f22b9d2d94586b2f05c581d546695e3d8f6a805cd7" + url: "https://pub.dev" + source: hosted + version: "1.2.0" characters: dependency: transitive description: @@ -249,14 +273,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" - fast_cached_network_image: - dependency: "direct main" - description: - name: fast_cached_network_image - sha256: "91f1d48d10e2916b83a1e7545c1eaf752f85b32acfb1473be1f9fa51d73afef0" - url: "https://pub.dev" - source: hosted - version: "1.2.9" ffi: dependency: transitive description: @@ -384,22 +400,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.2" - hive: - dependency: transitive - description: - name: hive - sha256: "8dcf6db979d7933da8217edcec84e9df1bdb4e4edc7fc77dbd5aa74356d6d941" - url: "https://pub.dev" - source: hosted - version: "2.2.3" - hive_flutter: - dependency: transitive - description: - name: hive_flutter - sha256: dca1da446b1d808a51689fb5d0c6c9510c0a2ba01e22805d492c73b68e33eecc - url: "https://pub.dev" - source: hosted - version: "1.1.0" http: dependency: transitive description: @@ -608,6 +608,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + octo_image: + dependency: transitive + description: + name: octo_image + sha256: "45b40f99622f11901238e18d48f5f12ea36426d8eced9f4cbf58479c7aa2430d" + url: "https://pub.dev" + source: hosted + version: "2.0.0" package_config: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0b8d466..35015e8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,7 +42,6 @@ dependencies: responsive_sizer: ^3.3.1 path_provider: ^2.1.3 shimmer: ^3.0.0 - fast_cached_network_image: ^1.2.9 auto_size_text: ^3.0.0 text_scroll: ^0.2.0 grouped_list: ^5.1.2 @@ -55,6 +54,7 @@ dependencies: json_annotation: ^4.9.0 shared_preferences: ^2.2.3 dynamic_color: ^1.7.0 + cached_network_image: ^3.3.1 dev_dependencies: build_runner: ^2.4.9