Skip to content

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

Open

Description

@lemmerel

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

Activity

  1. dnfield commented on Mar 13, 2023

    @dnfield
    Owner

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

  2. lemmerel commented on Mar 13, 2023

    @lemmerel
    Author

    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.

  3. lemmerel commented on Mar 13, 2023

    @lemmerel
    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?

  4. dnfield commented on Mar 13, 2023

    @dnfield
    Owner

    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.

  5. lemmerel commented on Mar 14, 2023

    @lemmerel
    Author

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

  6. lemmerel commented on Apr 4, 2023

    @lemmerel
    Author

    Any news here?

  7. lemmerel commented on Apr 6, 2023

    @lemmerel
    Author
  8. dnfield commented on Apr 10, 2023

    @dnfield
    Owner

    This has been waiting on dnfield/vector_graphics#196

  9. lemmerel commented on Apr 10, 2023

    @lemmerel
    Author
  10. dnfield commented on Apr 10, 2023

    @dnfield
    Owner

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

  11. glacials commented on Aug 1, 2023

    @glacials

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

  12. tanis2000 commented on May 13, 2024

    @tanis2000

    any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions