Skip to content

flutter_svg-v2.3.2

@francisrath francisrath tagged this 28 Oct 20:53
`SvgNetworkLoader.prepareMessage` returned `response.bodyBytes` without checking the status code, so a 404 or 503 HTML error page was handed to the SVG parser and failed with a misleading `StateError: Bad state: Invalid SVG data`. This PR makes it throw an `http.ClientException` naming the status code and URL for any status outside 200–299, so the real failure is visible.

It also moves closing an internally created client into a `finally`, so that client is closed on the error path too (and if `get` itself throws). Tests cover a 404 (throws, client still closed) and a 200 (returns the body).

Fixes https://github.com/flutter/flutter/issues/195162

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
Assets 2
Loading