diff --git a/lib/ui/common/image_loader.dart b/lib/ui/common/image_loader.dart index 87de46d20..2156d9b0a 100644 --- a/lib/ui/common/image_loader.dart +++ b/lib/ui/common/image_loader.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:cached_network_image/cached_network_image.dart'; class ImageLoader extends StatelessWidget { final String? url; @@ -17,23 +18,16 @@ class ImageLoader extends StatelessWidget { width: 0, height: 0, ) - : Image.network( - url!, + : CachedNetworkImage( + imageUrl: url!, width: fullSize ? null : width, height: fullSize ? null : height, - loadingBuilder: (BuildContext context, Widget child, - ImageChunkEvent? loadingProgress) { - if (loadingProgress == null) return child; - return Center( - child: CircularProgressIndicator( - color: Theme.of(context).colorScheme.secondary, - value: loadingProgress.expectedTotalBytes != null - ? loadingProgress.cumulativeBytesLoaded / - loadingProgress.expectedTotalBytes! - : null, - ), - ); - }, + placeholder: (context, url) => Center( + child: CircularProgressIndicator( + color: Theme.of(context).colorScheme.secondary, + ), + ), + errorWidget: (context, url, error) => Icon(Icons.error), ); } } diff --git a/pubspec.lock b/pubspec.lock index f57345cc2..e4b323b93 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -161,6 +161,30 @@ packages: url: "https://pub.dev" source: hosted version: "8.6.1" + cached_network_image: + dependency: "direct main" + description: + name: cached_network_image + sha256: fd3d0dc1d451f9a252b32d95d3f0c3c487bc41a75eba2e6097cb0b9c71491b15 + url: "https://pub.dev" + source: hosted + version: "3.2.3" + cached_network_image_platform_interface: + dependency: transitive + description: + name: cached_network_image_platform_interface + sha256: bb2b8403b4ccdc60ef5f25c70dead1f3d32d24b9d6117cfc087f496b178594a7 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + cached_network_image_web: + dependency: transitive + description: + name: cached_network_image_web + sha256: b8eb814ebfcb4dea049680f8c1ffb2df399e4d03bf7a352c775e26fa06e02fa0 + url: "https://pub.dev" + source: hosted + version: "1.0.2" characters: dependency: transitive description: @@ -446,6 +470,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_blurhash: + dependency: transitive + description: + name: flutter_blurhash + sha256: "05001537bd3fac7644fa6558b09ec8c0a3f2eba78c0765f88912882b1331a5c6" + url: "https://pub.dev" + source: hosted + version: "0.7.0" flutter_cache_manager: dependency: transitive description: @@ -867,6 +899,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + octo_image: + dependency: transitive + description: + name: octo_image + sha256: "107f3ed1330006a3bea63615e81cf637433f5135a52466c7caa0e7152bca9143" + url: "https://pub.dev" + source: hosted + version: "1.0.2" package_config: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index b99b568b7..ad9fa854d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,6 +55,7 @@ dependencies: just_audio: ^0.9.31 just_audio_background: ^0.0.1-beta.9 device_info_plus: ^9.1.2 + cached_network_image: ^3.2.3 dev_dependencies: build_runner: 2.0.2 flutter_test: