SvgPicture.network - Unhandled Exception: HttpException: Could not get network asset
When using SvgPicture.Network and the image could not be found, it throws the unhandled exception:
Unhandled Exception: HttpException: Could not get network asset, uri = http://127.0.0.1:1323/icon/person.svg
Version 2.0.3.
Could be fixed with try/catch and a parameter onException (as placeholderBuilder doesn't seem to affect it).
I'm trying to remember how this works with Image.network. But.. I think throwing an exception is the right thing to do here?
Thank you for your quick reply, @dnfield.
@override
Future<Uint8List?> prepareMessage(BuildContext? context) {
try {
return httpGet(url, headers: headers);
} catch (HttpException) {
throw HttpException;
}
}
Let me know what you think.
Widget build(BuildContext context) {
var res;
try {
res = SvgPicture.network(url,
color: color,
width: width,
height: height,
placeholderBuilder: placeholderBuilder);
} on HttpException {
res = Container();
}
return res;
}
What am I doing wrong?
Ok.
To do what you want here, you'd need some kind of errorBuilder parameter on the SvgPicture.network constructor.
Right now that's not implemented but probably isn't too hard.
I, and I'm sure all of your other very grateful users, would really appreciate it if you did that.
Any news here?
@dnfield
This has been waiting on https://github.com/dnfield/vector_graphics/pull/196
Ah my bad! Thank you so much for your work :)
On Mon, 10 Apr 2023 at 18:48, Dan Field @.***> wrote:
This has been waiting on dnfield/vector_graphics#196 https://github.com/dnfield/vector_graphics/pull/196
— Reply to this email directly, view it on GitHub https://github.com/dnfield/flutter_svg/issues/881#issuecomment-1502046928, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6F2KHSX45PWKFHSG7PN6W3XAQ2UJANCNFSM6AAAAAAVYY4QF4 . You are receiving this because you authored the thread.Message ID: @.***>
Next steps will be to publish new vector_graphics* and then use it in flutter_svg.
Thanks for your hard work! Seems like vector_graphics is all set, can this be pulled into flutter_svg?
any news on this?