Open olaripihlak opened 3 months ago
In case of image error, error is not cached when using memCacheHeight and memCacheWidth.
memCacheHeight
memCacheWidth
Started with Flutter version 3.16 and also reproducible in 3.19. Works correctly with Flutter 3.13.
Image error is cached and network call is only made once when using memCacheHeight and memCacheWidth.
Image error is not cached and network call is made every time when using memCacheHeight and memCacheWidth.
import 'dart:async'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; void main() { runApp(MaterialApp( home: Scaffold( appBar: AppBar(title: Text('Reload Image')), body: const MyImageWidget(), ), )); } class MyImageWidget extends StatefulWidget { const MyImageWidget({super.key}); @override MyImageWidgetState createState() => MyImageWidgetState(); } class MyImageWidgetState extends State<MyImageWidget> { static const imageCacheKey = 'one_day_cached_network_image_key'; static CacheManager cacheManagerInstance = CacheManager( Config( imageCacheKey, stalePeriod: const Duration(days: 1), ), ); Timer? _timer; @override void initState() { super.initState(); _startTimer(); } @override void dispose() { _timer?.cancel(); super.dispose(); } void _startTimer() { const duration = Duration(seconds: 5); _timer = Timer.periodic(duration, (timer) { if (mounted) { setState(() {}); } }); } @override Widget build(BuildContext context) { return CachedNetworkImage( imageUrl: "https://random/icon.png", memCacheHeight: 100, memCacheWidth: 100, imageBuilder: (context, imageProvider) => Image(image: imageProvider), errorWidget: (context, url, error) => const Icon(Icons.nearby_error_outlined), ); } }
Version: 3.3.1
Platform:
🔙 Regression
In case of image error, error is not cached when using
memCacheHeight
andmemCacheWidth
.Started with Flutter version 3.16 and also reproducible in 3.19. Works correctly with Flutter 3.13.
Old (and correct) behavior
Image error is cached and network call is only made once when using
memCacheHeight
andmemCacheWidth
.Current behavior
Image error is not cached and network call is made every time when using
memCacheHeight
andmemCacheWidth
.Reproduction steps
Configuration
Version: 3.3.1
Platform: