Skip to content

Suppress Markdown images by default and add LlmMessageStyle.imageBuilder - #206

Merged
yjbanov merged 2 commits into
flutter:mainfrom
yjbanov:fix-markdown-images
Nov 17, 2026
Merged

yjbanov merged 2 commits into
flutter:mainfrom
yjbanov:fix-markdown-images

Conversation

@yjbanov

@yjbanov yjbanov commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes b/528774200
Fixes b/584414975

LlmMessageView previously rendered LLM output through MarkdownBody without specifying an imageBuilder, causing flutter_markdown_plus to use kDefaultImageBuilder and automatically fetch remote image URLs or open local file paths from untrusted model output.

  • Suppress Markdown images in LlmMessageView by default (SizedBox.shrink()).
  • Add an optional imageBuilder property to LlmMessageStyle (defaults to null) so applications can explicitly opt in to custom Markdown image rendering.
  • Make LlmMessageStyle final.
  • Suppress Markdown images in the example RecipeResponseView and forward imageBuilder in _darkLlmMessageStyle().
  • Add unit and widget tests in test/llm_message_image_test.dart and bump version to 1.1.0.

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

`LlmMessageView` previously rendered LLM output through `MarkdownBody` without specifying an `imageBuilder`, causing `flutter_markdown_plus` to use `kDefaultImageBuilder` and automatically fetch remote image URLs or open local file paths from untrusted model output.

- Suppress Markdown images in `LlmMessageView` by default (`SizedBox.shrink()`).
- Add an optional `imageBuilder` property to `LlmMessageStyle` (defaults to `null`) so applications can explicitly opt in to custom Markdown image rendering.
- Make `LlmMessageStyle` `final`.
- Suppress Markdown images in the example `RecipeResponseView` and forward `imageBuilder` in `_darkLlmMessageStyle()`.
- Add unit and widget tests in `test/llm_message_image_test.dart` and bump version to `1.1.0`.

@ditman ditman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like a breaking change, so it probably should roll a major version.

Also, the lints:

   info - example/lib/recipes/views/recipe_list_view.dart:5:1 - 'package:flutter/material.dart' is deprecated and shouldn't be used. Use package:material_ui/material_ui.dart instead. This feature was deprecated after v3.47.0-0.0.pre. Try replacing the use of the deprecated member with the replacement. - deprecated_member_use

We need to migrate to package:material_ui (that probably can happen in a separate PR)

Comment thread CHANGELOG.md Resolved
@yjbanov
yjbanov merged commit 6fe004c into flutter:main Nov 17, 2026
7 of 9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants