This document describes the recent improvements made to the slideshow image loading experience.
What changed:
- Replaced the circular progress indicator with a blurred version of the image
- The placeholder shows a low-resolution (100x100px) version of the image with a 20px blur effect
- This provides a better visual experience while the full-resolution image loads
Benefits:
- Users see a preview of the image immediately
- More elegant and professional appearance
- Reduces perceived loading time
- Maintains visual continuity
What changed:
- Implemented automatic precaching of the next 3 images in the slideshow
- Precaching happens:
- When slides are first loaded
- After each slide transition (next or previous)
- Uses Flutter's
precacheImage()withCachedNetworkImageProvider
Benefits:
- Images are ready before they're displayed
- Smoother transitions between slides
- Better user experience, especially on slower networks
- Reduces waiting time between slides
Widget _buildBlurredPlaceholder(String url) {
return Stack(
fit: StackFit.expand,
children: [
CachedNetworkImage(
imageUrl: url,
fit: BoxFit.cover,
memCacheWidth: 100, // Low resolution for quick loading
memCacheHeight: 100,
imageBuilder: (context, imageProvider) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.cover,
),
),
child: BackdropFilter(
filter: ui.ImageFilter.blur(sigmaX: 20.0, sigmaY: 20.0),
child: Container(
color: Colors.black.withValues(alpha: 0.3),
),
),
);
},
),
],
);
}void _precacheNextImages() {
if (_slides.isEmpty || !mounted) return;
for (int i = 1; i <= _precacheCount; i++) {
final nextIndex = (_currentIndex + i) % _slides.length;
final imageUrl = _slides[nextIndex].imageUrl;
precacheImage(
CachedNetworkImageProvider(imageUrl),
context,
).catchError((error) {
debugPrint('Error precaching image at index $nextIndex: $error');
});
}
}-
Precache count: Currently set to 3 images ahead
- Can be modified via
_precacheCountconstant - Higher values use more memory but provide smoother experience
- Can be modified via
-
Blur intensity: Currently set to 20px (sigmaX and sigmaY)
- Can be adjusted in
_buildBlurredPlaceholder() - Higher values create more blur
- Can be adjusted in
-
Placeholder resolution: Currently 100x100px
- Can be adjusted via
memCacheWidthandmemCacheHeight - Lower values load faster but may look more pixelated
- Can be adjusted via
- Precaching 3 images at 1920x1080 resolution uses approximately 20-30MB of memory
- Blurred placeholders use minimal memory (100x100px = ~30KB per image)
cached_network_imagehandles disk caching automatically
- Images are downloaded once and cached on disk
- Precaching happens in the background without blocking UI
- Failed precache attempts are logged but don't affect user experience
- Slow Network: Test on 3G/4G to verify blurred placeholders appear quickly
- Fast Network: Verify smooth transitions with precaching
- Memory: Monitor memory usage with multiple slides
- Edge Cases: Test with network interruptions and failed image loads
Possible enhancements:
- Adaptive precaching based on network speed
- Progressive image loading (low-res → high-res)
- Preload images in both directions (forward and backward)
- Smart precaching based on user behavior