flutter_svg icon indicating copy to clipboard operation
flutter_svg copied to clipboard

Catching error or having an "error" placeholder

Open vd3d opened this issue 1 year ago • 5 comments

Hi,

First thanks for the library :-)

I'm currently using "SvgPicture.network" with a placeholder, but when there are internet connection issues, I got an exception in the debug log.

But, the placeholder continues to animate, I would like to put a default icon or just an empty one.

I have see multiples requests like mines: https://github.com/dnfield/vector_graphics/pull/196#commits-pushed-40ee8bb https://github.com/dnfield/flutter_svg/issues/881

... and more...

I have the feeling it has been implemented, or partially, but I can't figure out how I can handle such cases (which are commons)

Thanks for your help

PS: I haven't find any solution on this forum, sorry

vd3d avatar Oct 30 '23 17:10 vd3d

+1 .. kindly add an error builder.

animator avatar Dec 16 '23 01:12 animator

@animator @vd3d Instead of waiting for an errorBuilder property to be added, you can actually handle this yourself by bypassing svgPicture.network, handle the loading of the URL yourself via DIO or Http package and then return an SvgPicture yourself from the http get request. if there is an exception you can trap this and handle appropriately - i.e add a retry button to re-load the resource , in situations where there is no network. This approach with Riverpod for caching works a treat and means there is absolutely no need to use svgPicture.network.

alexda12 avatar Dec 27 '23 21:12 alexda12

@alexda12 I am using SVG string which can be a faulty SVG XML string. Thus, the need of an error builder in case there is any issue in parsing or rendering. This has nothing to do with network.

animator avatar Jan 06 '24 23:01 animator