| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -2,9 +2,9 @@ part of '../../neon.dart'; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					final _cacheManager = DefaultCacheManager(); | 
					 | 
					 | 
					 | 
					final _cacheManager = DefaultCacheManager(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					abstract class NeonCachedImage extends StatelessWidget { | 
					 | 
					 | 
					 | 
					abstract class NeonCachedImage extends StatefulWidget { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  const NeonCachedImage({ | 
					 | 
					 | 
					 | 
					  const NeonCachedImage({ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    required this.future, | 
					 | 
					 | 
					 | 
					    required this.getImageFile, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    this.isSvgHint = false, | 
					 | 
					 | 
					 | 
					    this.isSvgHint = false, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    this.height, | 
					 | 
					 | 
					 | 
					    this.height, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    this.width, | 
					 | 
					 | 
					 | 
					    this.width, | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -14,7 +14,7 @@ abstract class NeonCachedImage extends StatelessWidget { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    super.key, | 
					 | 
					 | 
					 | 
					    super.key, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  }); | 
					 | 
					 | 
					 | 
					  }); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  final Future<File> future; | 
					 | 
					 | 
					 | 
					  final Future<File> Function() getImageFile; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  final bool isSvgHint; | 
					 | 
					 | 
					 | 
					  final bool isSvgHint; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  final double? height; | 
					 | 
					 | 
					 | 
					  final double? height; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -25,48 +25,66 @@ abstract class NeonCachedImage extends StatelessWidget { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  final Color? iconColor; | 
					 | 
					 | 
					 | 
					  final Color? iconColor; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  @override | 
					 | 
					 | 
					 | 
					  @override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  Widget build(final BuildContext context) => FutureBuilder<File>( | 
					 | 
					 | 
					 | 
					  State<NeonCachedImage> createState() => _NeonCachedImageState(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        future: future, | 
					 | 
					 | 
					 | 
					} | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        builder: (final context, final fileSnapshot) { | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          if (fileSnapshot.hasData) { | 
					 | 
					 | 
					 | 
					class _NeonCachedImageState extends State<NeonCachedImage> { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            final content = fileSnapshot.data!.readAsBytesSync(); | 
					 | 
					 | 
					 | 
					  late Future<File> future = widget.getImageFile(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  @override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  Widget build(final BuildContext context) => Center( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        child: FutureBuilder<File>( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          future: future, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          builder: (final context, final fileSnapshot) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (fileSnapshot.hasData) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              final content = fileSnapshot.data!.readAsBytesSync(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            try { | 
					 | 
					 | 
					 | 
					              try { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              // TODO: Is this safe enough? | 
					 | 
					 | 
					 | 
					                // TODO: Is this safe enough? | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              if (isSvgHint || utf8.decode(content).contains('<svg')) { | 
					 | 
					 | 
					 | 
					                if (widget.isSvgHint || utf8.decode(content).contains('<svg')) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                return SvgPicture.memory( | 
					 | 
					 | 
					 | 
					                  return SvgPicture.memory( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                  content, | 
					 | 
					 | 
					 | 
					                    content, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                  height: height, | 
					 | 
					 | 
					 | 
					                    height: widget.height, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                  width: width, | 
					 | 
					 | 
					 | 
					                    width: widget.width, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                  fit: fit ?? BoxFit.contain, | 
					 | 
					 | 
					 | 
					                    fit: widget.fit ?? BoxFit.contain, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                  color: svgColor, | 
					 | 
					 | 
					 | 
					                    color: widget.svgColor, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                ); | 
					 | 
					 | 
					 | 
					                  ); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              } catch (_) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                // If the data is not UTF-8 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              } | 
					 | 
					 | 
					 | 
					              } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } catch (_) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              // If the data is not UTF-8 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return Image.memory( | 
					 | 
					 | 
					 | 
					              return Image.memory( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              content, | 
					 | 
					 | 
					 | 
					                content, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              height: height, | 
					 | 
					 | 
					 | 
					                height: widget.height, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              width: width, | 
					 | 
					 | 
					 | 
					                width: widget.width, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              fit: fit, | 
					 | 
					 | 
					 | 
					                fit: widget.fit, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              gaplessPlayback: true, | 
					 | 
					 | 
					 | 
					                gaplessPlayback: true, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ); | 
					 | 
					 | 
					 | 
					              ); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          if (fileSnapshot.hasError) { | 
					 | 
					 | 
					 | 
					            if (fileSnapshot.hasError) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            return Icon( | 
					 | 
					 | 
					 | 
					              return NeonException( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              Icons.error_outline, | 
					 | 
					 | 
					 | 
					                fileSnapshot.error, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              size: height != null && width != null ? min(height!, width!) : height ?? width, | 
					 | 
					 | 
					 | 
					                onRetry: () { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              color: iconColor, | 
					 | 
					 | 
					 | 
					                  setState(() { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    // ignore: discarded_futures | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    future = widget.getImageFile(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                  }); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                }, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                onlyIcon: true, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                iconSize: widget.height != null && widget.width != null | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    ? min(widget.height!, widget.width!) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    : widget.height ?? widget.width, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                color: widget.iconColor ?? Colors.red, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            return SizedBox( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              width: widget.width, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              child: NeonLinearProgressIndicator( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                color: widget.iconColor, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					              ), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ); | 
					 | 
					 | 
					 | 
					            ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          } | 
					 | 
					 | 
					 | 
					          }, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          return SizedBox( | 
					 | 
					 | 
					 | 
					        ), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            width: width, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            child: NeonLinearProgressIndicator( | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              color: iconColor, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ), | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          ); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        }, | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ); | 
					 | 
					 | 
					 | 
					      ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					 | 
					
  |