Repository navigation
feat(a2ui_flutter): render data: image URLs in Image - #3963
Conversation
web_core accepts data: media URLs since a2ui-project#3108, but the Flutter Image showed the broken-image icon for anything other than http(s). Decode a data: URL of an image/* type into a MemoryImage that compares by URL, so a rebuild reuses the cached decode. Other types and undecodable content keep the broken-image icon.
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
Hi @karolkulesza, Thank you for raising the pr to fix the issue. We have verified the pr and it does resolve the issue. I will escalate this to team to review. Thank you for your patience and understanding. |
|
From triage bot, analysis: For humansTL;DR Summary: Targeted issues: Suggestion: No team member has reviewed the PR yet. The PR meets two of the review criteria:
It fails the overlap criterion. #4120, a draft from 2026-11-10, routes the Flutter media URLs through the URL security policy of #4045. Its new #4280, which migrates
To adjust the analysis and apply its suggestion, run in your a2ui checkout: tools/internal/triage/triage_ui.sh https://github.com/a2ui-project/a2ui/pull/3963For softwareThis analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision. 🤖 Agent-generated |
nan-yu
left a comment
There was a problem hiding this comment.
The fix looks good. Thanks for the contribution.
nan-yu
left a comment
There was a problem hiding this comment.
One thing to fix before this merges: the CHANGELOG entry is in an already-released section. Details inline.
🤖 Agent-generated
…Image (#4045) Main's Image gained data: image support (#3963) while this branch added A2uiMediaImage for the same job. Merge them into A2uiMediaImage: it fetches http(s) URLs with NetworkImage, decodes data: URLs of an image/* type with main's cache-friendly provider, and builds its error widget for any other URL (such as a relative one) without loading anything. Image, the Video poster, and the Markdown image builders all use it, so every image URL goes through the URL security policy first. Main's data: tests are kept; the non-image and MIME-less data: URLs they used now count as blocked by the baseline and render nothing.
…Image (#4045) Main's Image gained data: image support (#3963) while this branch added A2uiMediaImage for the same job. Merge them into A2uiMediaImage: it fetches http(s) URLs with NetworkImage, decodes data: URLs of an image/* type with main's cache-friendly provider, and builds its error widget for any other URL (such as a relative one) without loading anything. Image, the Video poster, and the Markdown image builders all use it, so every image URL goes through the URL security policy first. Main's data: tests are kept; the non-image and MIME-less data: URLs they used now count as blocked by the baseline and render nothing.
…Image (#4045) Main's Image gained data: image support (#3963) while this branch added A2uiMediaImage for the same job. Merge them into A2uiMediaImage: it fetches http(s) URLs with NetworkImage, decodes data: URLs of an image/* type with main's cache-friendly provider, and builds its error widget for any other URL (such as a relative one) without loading anything. Image, the Video poster, and the Markdown image builders all use it, so every image URL goes through the URL security policy first. Main's data: tests are kept; the non-image and MIME-less data: URLs they used now count as blocked by the baseline and render nothing.
…Image (#4045) Main's Image gained data: image support (#3963) while this branch added A2uiMediaImage for the same job. Merge them into A2uiMediaImage: it fetches http(s) URLs with NetworkImage, decodes data: URLs of an image/* type with main's cache-friendly provider, and builds its error widget for any other URL (such as a relative one) without loading anything. Image, the Video poster, and the Markdown image builders all use it, so every image URL goes through the URL security policy first. Main's data: tests are kept; the non-image and MIME-less data: URLs they used now count as blocked by the baseline and render nothing.
…Image (#4045) Main's Image gained data: image support (#3963) while this branch added A2uiMediaImage for the same job. Merge them into A2uiMediaImage: it fetches http(s) URLs with NetworkImage, decodes data: URLs of an image/* type with main's cache-friendly provider, and builds its error widget for any other URL (such as a relative one) without loading anything. Image, the Video poster, and the Markdown image builders all use it, so every image URL goes through the URL security policy first. Main's data: tests are kept; the non-image and MIME-less data: URLs they used now count as blocked by the baseline and render nothing.
…Image (#4045) Main's Image gained data: image support (#3963) while this branch added A2uiMediaImage for the same job. Merge them into A2uiMediaImage: it fetches http(s) URLs with NetworkImage, decodes data: URLs of an image/* type with main's cache-friendly provider, and builds its error widget for any other URL (such as a relative one) without loading anything. Image, the Video poster, and the Markdown image builders all use it, so every image URL goes through the URL security policy first. Main's data: tests are kept; the non-image and MIME-less data: URLs they used now count as blocked by the baseline and render nothing.
…Image (#4045) Main's Image gained data: image support (#3963) while this branch added A2uiMediaImage for the same job. Merge them into A2uiMediaImage: it fetches http(s) URLs with NetworkImage, decodes data: URLs of an image/* type with main's cache-friendly provider, and builds its error widget for any other URL (such as a relative one) without loading anything. Image, the Video poster, and the Markdown image builders all use it, so every image URL goes through the URL security policy first. Main's data: tests are kept; the non-image and MIME-less data: URLs they used now count as blocked by the baseline and render nothing.
Description
The basic
Imagein a2ui_flutter showed the broken-image icon for every URL that wasn'thttp://orhttps://, so an inline base64data:image rendered on the web but not in Flutter. web_core has alloweddata:media URLs since #3108, and #3766 does the same for SwiftUI.Changes:
Imagerenders adata:URL whose MIME type isimage/*from its bytes. The type check ignores case, soDATA:IMAGE/PNG;...works too.fit,variantanddescriptionwork as they do for network images.data:URL of another type (includingdata:;base64,..., whose type defaults totext/plain), one that doesn't parse, or image bytes that don't decode show the broken-image icon. The icon is labelled bydescription, as for a network image that fails to load.MemoryImagesubclass that compares equal by URL. A plainMemoryImagecompares by the identity of its bytes, so every rebuild would have decoded the image again. With this subclass, a rebuild with the same URL uses the cached image.Image.network(url)is nowImage(image: NetworkImage(url)).Image.networkbuilds the same thing when no cache size is given, so network images don't change.Flutter accepts only
image/*data URLs, while web_core accepts anydata:URL and leaves the rest to the browser.Imagecan't show other types anyway.Video,AudioPlayerand theVideoposter are unchanged.Two known differences from the browser, which I left for a follow-up if anyone needs them: base64 with line breaks or spaces doesn't parse in Dart, so it shows the broken icon, and the base64 is decoded again on each rebuild before the cache lookup.
Fixes #3960
Related: #3108, #3766
Testing:
test/catalog/basic/image_test.dart: a 1×1 PNG data URL renders from its bytes at its natural size withfitapplied and no network request; an upper-case scheme and MIME type; thedescriptionlabel; a rebuild keeps the same image provider; a non-image type, a missing type and malformed base64 fall back to the labelled broken icon; image bytes that don't decode fall back without an exception.flutter testindart/a2ui_flutter: 420 tests pass.dart analyze: no issues.dart format: no changes.prettier --check CHANGELOG.md: clean.Pre-launch Checklist
One time:
For this PR:
Imageaccepts.)If you need help, consider asking for advice on the discussion board.