diff --git a/lib/widgets/universal_image.dart b/lib/widgets/universal_image.dart index 807bb54..600776a 100644 --- a/lib/widgets/universal_image.dart +++ b/lib/widgets/universal_image.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:material_symbols_icons/symbols.dart'; import 'package:styled_widget/styled_widget.dart'; import 'package:flutter_animate/flutter_animate.dart'; +import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'; class UniversalImage extends StatelessWidget { final String url; @@ -14,6 +15,7 @@ class UniversalImage extends StatelessWidget { final bool noProgressIndicator; final bool noErrorWidget; final double? cacheWidth, cacheHeight; + final FilterQuality filterQuality; const UniversalImage( this.url, { @@ -25,45 +27,43 @@ class UniversalImage extends StatelessWidget { this.noErrorWidget = false, this.cacheWidth, this.cacheHeight, + this.filterQuality = FilterQuality.high, }); @override Widget build(BuildContext context) { final devicePixelRatio = MediaQuery.of(context).devicePixelRatio; - final double? resizeHeight = - cacheHeight != null ? (cacheHeight! * devicePixelRatio) : null; - final double? resizeWidth = - cacheWidth != null ? (cacheWidth! * devicePixelRatio) : null; + final double? resizeHeight = cacheHeight != null ? (cacheHeight! * devicePixelRatio) : null; + final double? resizeWidth = cacheWidth != null ? (cacheWidth! * devicePixelRatio) : null; return Image( - image: ResizeImage( - UniversalImage.provider(url), - width: resizeWidth?.round(), - height: resizeHeight?.round(), - policy: ResizeImagePolicy.fit, - ), + filterQuality: filterQuality, + image: kIsWeb + ? UniversalImage.provider(url) + : ResizeImage( + UniversalImage.provider(url), + width: resizeWidth?.round(), + height: resizeHeight?.round(), + policy: ResizeImagePolicy.fit, + ), width: width, height: height, fit: fit, loadingBuilder: noProgressIndicator ? null - : (BuildContext context, Widget child, - ImageChunkEvent? loadingProgress) { + : (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { if (loadingProgress == null) return child; return Center( child: TweenAnimationBuilder( tween: Tween( begin: 0, end: loadingProgress.expectedTotalBytes != null - ? loadingProgress.cumulativeBytesLoaded / - loadingProgress.expectedTotalBytes! + ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! : 0, ), duration: const Duration(milliseconds: 300), builder: (context, value, _) => CircularProgressIndicator( - value: loadingProgress.expectedTotalBytes != null - ? value.toDouble() - : null, + value: loadingProgress.expectedTotalBytes != null ? value.toDouble() : null, ), ), ); @@ -94,10 +94,13 @@ class UniversalImage extends StatelessWidget { } static ImageProvider provider(String url) { - if (!kIsWeb && (Platform.isAndroid || Platform.isIOS || Platform.isMacOS)) { - return CachedNetworkImageProvider(url); - } - return NetworkImage(url); + // This place used to use network image or cached network image depending on the platform. + // But now the cached network image is working on every platform. + // So we just use it now. + return CachedNetworkImageProvider( + url, + imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet, + ); } } diff --git a/pubspec.lock b/pubspec.lock index 5b6d463..3859e81 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -122,50 +122,50 @@ packages: dependency: transitive description: name: build - sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0 url: "https://pub.dev" source: hosted - version: "2.4.1" + version: "2.4.2" build_config: dependency: transitive description: name: build_config - sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" build_daemon: dependency: transitive description: name: build_daemon - sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9" + sha256: "294a2edaf4814a378725bfe6358210196f5ea37af89ecd81bfa32960113d4948" url: "https://pub.dev" source: hosted - version: "4.0.2" + version: "4.0.3" build_resolvers: dependency: transitive description: name: build_resolvers - sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + sha256: "99d3980049739a985cf9b21f30881f46db3ebc62c5b8d5e60e27440876b1ba1e" url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.4.3" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d" + sha256: "74691599a5bc750dc96a6b4bfd48f7d9d66453eab04c7f4063134800d6a5c573" url: "https://pub.dev" source: hosted - version: "2.4.13" + version: "2.4.14" build_runner_core: dependency: transitive description: name: build_runner_core - sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0 + sha256: "22e3aa1c80e0ada3722fe5b63fd43d9c8990759d0a2cf489c8c5d7b2bdebc021" url: "https://pub.dev" source: hosted - version: "7.3.2" + version: "8.0.0" built_collection: dependency: transitive description: @@ -178,10 +178,10 @@ packages: dependency: transitive description: name: built_value - sha256: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb + sha256: "28a712df2576b63c6c005c465989a348604960c0958d28be5303ba9baa841ac2" url: "https://pub.dev" source: hosted - version: "8.9.2" + version: "8.9.3" cached_network_image: dependency: "direct main" description: @@ -490,10 +490,10 @@ packages: dependency: "direct main" description: name: file_picker - sha256: "16dc141db5a2ccc6520ebb6a2eb5945b1b09e95085c021d9f914f8ded7f1465c" + sha256: c2376a6aae82358a9f9ccdd7d1f4006d08faa39a2767cce01031d9f593a8bd3b url: "https://pub.dev" source: hosted - version: "8.1.4" + version: "8.1.6" file_saver: dependency: "direct main" description: @@ -692,10 +692,10 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398" + sha256: "615a505aef59b151b46bbeef55b36ce2b6ed299d160c51d84281946f0aa0ce0e" url: "https://pub.dev" source: hosted - version: "2.0.23" + version: "2.0.24" flutter_shaders: dependency: transitive description: @@ -742,10 +742,10 @@ packages: dependency: transitive description: name: flutter_webrtc - sha256: "4838217405c42cce422698eacc9c2e17089b9c05322be899c0a725107dcddbdc" + sha256: "430859fb5b763d7556d06ef287cfca582e17d9a2dc36da26017f25a5c0b2523e" url: "https://pub.dev" source: hosted - version: "0.12.3" + version: "0.12.4" freezed: dependency: "direct dev" description: @@ -774,10 +774,10 @@ packages: dependency: "direct main" description: name: gal - sha256: "54c9b72528efce7c66234f3b6dd01cb0304fd8af8196de15571d7bdddb940977" + sha256: "2771519c8b29f784d5e27f4efc2667667eef51c6c47cccaa0435a8fe8aa208e4" url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.3.1" gap: dependency: "direct main" description: @@ -870,10 +870,10 @@ packages: dependency: transitive description: name: http_multi_server - sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 url: "https://pub.dev" source: hosted - version: "3.2.1" + version: "3.2.2" http_parser: dependency: transitive description: @@ -894,10 +894,10 @@ packages: dependency: transitive description: name: image - sha256: "599d08e369969bdf83138f5b4e0a7e823d3f992f23b8a64dd626877c37013533" + sha256: b50b415345578583de0f1cf4c7bd389f164de0b316d890c707b41133047dbc2a url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.5.1" image_picker: dependency: "direct main" description: @@ -1598,10 +1598,10 @@ packages: dependency: "direct main" description: name: shared_preferences - sha256: "95f9997ca1fb9799d494d0cb2a780fd7be075818d59f00c43832ed112b158a82" + sha256: "3c7e73920c694a436afaf65ab60ce3453d91f84208d761fbd83fc21182134d93" url: "https://pub.dev" source: hosted - version: "2.3.3" + version: "2.3.4" shared_preferences_android: dependency: transitive description: @@ -1691,10 +1691,10 @@ packages: dependency: transitive description: name: source_helper - sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd" + sha256: "86d247119aedce8e63f4751bd9626fc9613255935558447569ad42f9f5b48b3c" url: "https://pub.dev" source: hosted - version: "1.3.4" + version: "1.3.5" source_span: dependency: transitive description: @@ -1771,10 +1771,10 @@ packages: dependency: transitive description: name: stream_transform - sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: @@ -2019,10 +2019,10 @@ packages: dependency: transitive description: name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + sha256: "69da27e49efa56a15f8afe8f4438c4ec02eff0a117df1b22ea4aad194fe1c104" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" web: dependency: transitive description: @@ -2096,5 +2096,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.6.0-0 <4.0.0" + dart: ">=3.6.0 <4.0.0" flutter: ">=3.24.0" diff --git a/pubspec.yaml b/pubspec.yaml index b4eecda..95457a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: surface -description: "A new Flutter project." +description: "The application for Solar Network" # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: "none" # Remove this line if you wish to publish to pub.dev @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 2.1.1+31 +version: 2.1.1+32 environment: sdk: ^3.5.4 @@ -61,7 +61,7 @@ dependencies: relative_time: ^5.0.0 image_picker: ^1.1.2 cross_file: ^0.3.4+2 - file_picker: 8.1.4 # pinned due to compile failed on android, https://github.com/miguelpruivo/flutter_file_picker/issues/1643 + file_picker: ^8.1.6 # pinned due to compile failed on android, https://github.com/miguelpruivo/flutter_file_picker/issues/1643 croppy: ^1.3.1 flutter_expandable_fab: ^2.3.0 dropdown_button2: ^2.3.9