Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SvgPicture.network - Unhandled Exception: HttpException: Could not get network asset #881

Open
lemmerel opened this issue Mar 13, 2023 · 12 comments

Comments

@lemmerel
Copy link

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).

@dnfield
Copy link
Owner

dnfield commented Mar 13, 2023

I'm trying to remember how this works with Image.network. But.. I think throwing an exception is the right thing to do here?

@lemmerel
Copy link
Author

lemmerel commented Mar 13, 2023

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.

@lemmerel
Copy link
Author

      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?

@dnfield
Copy link
Owner

dnfield commented Mar 13, 2023

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.

@lemmerel
Copy link
Author

I, and I'm sure all of your other very grateful users, would really appreciate it if you did that.

@lemmerel
Copy link
Author

lemmerel commented Apr 4, 2023

Any news here?

@lemmerel
Copy link
Author

lemmerel commented Apr 6, 2023

@dnfield

@dnfield
Copy link
Owner

dnfield commented Apr 10, 2023

This has been waiting on dnfield/vector_graphics#196

@lemmerel
Copy link
Author

lemmerel commented Apr 10, 2023 via email

@dnfield
Copy link
Owner

dnfield commented Apr 10, 2023

Next steps will be to publish new vector_graphics* and then use it in flutter_svg.

@glacials
Copy link

glacials commented Aug 1, 2023

Thanks for your hard work! Seems like vector_graphics is all set, can this be pulled into flutter_svg?

@tanis2000
Copy link

any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants