在 flutter 中调整 Markdown 图像的大小
I need to resize a local image from the assets folder in my markdown file.
I currently have this image that does display in my .md file.
I need to resize the image to make it a bit smaller.
Is it possible with the current package?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用内联 HTML
![]()
并提供大小。或
更多和参考:在 Markdown 中更改图像大小
You can use inline HTML
<img/>
with providing size.Or
More and ref: Changing image size in Markdown
这是关于此的 github 讨论,https://gist.github.com/uupaa/f77d2bcf4dc7a294d109
This the github discussion on this, https://gist.github.com/uupaa/f77d2bcf4dc7a294d109
当具体考虑 Flutter Markdown 插件 时,调整图像大小的一个好方法是使用
imageBuilder
参数。对于您的示例,以下是返回
Markdown
小部件时调整图像大小的代码:对于其他情况(例如网络图像),您可以从名为
kDefaultImageBuilder 的默认函数中找到灵感
当未指定imageBuilder
时:https://github.com/flutter/packages/blob/ec4a54604ff5043891bae98498116a714061baa5/packages/flutter_markdown/lib/src/_functions_io.dart#L18-L42When considering specifically the Flutter Markdown plugin, a good way to resize images is to make use of the
imageBuilder
parameter.For your example, here is the code that would resize the image when returning the
Markdown
Widget:For other cases such as network images for example, you can find inspiration from the default function called,
kDefaultImageBuilder
when noimageBuilder
is specified: https://github.com/flutter/packages/blob/ec4a54604ff5043891bae98498116a714061baa5/packages/flutter_markdown/lib/src/_functions_io.dart#L18-L42您可以使用 Flutter Markdown 指定 URL 末尾的图像大小,如下所示:

这会将图像大小调整为宽度 80 像素、高度 50 像素
You can specify the size of the image at the end of the URL using Flutter Markdown like this :

This will resize the image to a width of 80 pixels for a height of 50 pixels