From 3d71e5ba357369234f902f877aea8b5340da45e0 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Fri, 13 Sep 2024 14:12:18 -0300 Subject: [PATCH] fix img cache --- .../card_item_template_component_widget.dart | 7 ++++-- .../details_component_widget.dart | 2 ++ lib/pages/pets_page/pets_page_widget.dart | 1 + pubspec.lock | 24 +++++++++++++++++++ pubspec.yaml | 1 + 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart index 49f979ad..fb19fd44 100644 --- a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart +++ b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart @@ -98,10 +98,13 @@ class _CardItemTemplateComponentWidgetState } Widget _generateImage() { + CachedNetworkImage.evictFromCache(widget.imagePath ?? ''); return ClipRRect( borderRadius: BorderRadius.circular(20), - child: Image.network( - widget.imagePath ?? '', + child: CachedNetworkImage( + fadeInDuration: const Duration(milliseconds: 500), + fadeOutDuration: const Duration(milliseconds: 500), + imageUrl: widget.imagePath ?? '', fit: BoxFit.cover, width: 90, height: 90, diff --git a/lib/components/templates_components/details_component/details_component_widget.dart b/lib/components/templates_components/details_component/details_component_widget.dart index ffaf25f6..6aefc08a 100644 --- a/lib/components/templates_components/details_component/details_component_widget.dart +++ b/lib/components/templates_components/details_component/details_component_widget.dart @@ -65,6 +65,7 @@ class _DetailsComponentWidgetState extends State { @override Widget build(BuildContext context) { context.watch(); + CachedNetworkImage.evictFromCache(widget.imagePath ?? ''); return Container( constraints: BoxConstraints( @@ -93,6 +94,7 @@ class _DetailsComponentWidgetState extends State { fadeOutDuration: const Duration(milliseconds: 100), imageUrl: widget.imagePath ?? '', fit: BoxFit.cover, + useOldImageOnUrlChange: true, ), ), SizedBox(height: MediaQuery.of(context).size.height * 0.03), diff --git a/lib/pages/pets_page/pets_page_widget.dart b/lib/pages/pets_page/pets_page_widget.dart index 1c2075be..007288cf 100644 --- a/lib/pages/pets_page/pets_page_widget.dart +++ b/lib/pages/pets_page/pets_page_widget.dart @@ -103,6 +103,7 @@ class _PetsPageWidgetState extends State ? ValidatorUtil.formatDateTimePicker(widget.pet['birthdayDate']) : '' : ''); + _model.textFieldFocusData ??= FocusNode(); _model.textControllerObservation ??= TextEditingController( diff --git a/pubspec.lock b/pubspec.lock index 34dfa4d3..b97cf65c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -289,6 +289,14 @@ 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: @@ -701,6 +709,22 @@ packages: url: "https://pub.dev" source: hosted version: "6.2.1" + 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" html: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 148e4c8b..c8fba9ae 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: csv: 6.0.0 device_info_plus: 10.1.0 firebase_messaging: 15.0.1 + fast_cached_network_image: ^1.2.9 dropdown_button2: 2.3.9 easy_debounce: 2.0.3 equatable: 2.0.5