在 flutter 中调整 Markdown 图像的大小

发布于 2025-01-11 13:15:19 字数 249 浏览 4 评论 0原文

我需要调整 Markdown 文件中资产文件夹中的本地图像的大小。

我目前的 .md 文件中确实显示了此图像。

输入图片此处描述

我需要调整图像大小以使其小一点。

目前的套餐可以吗?

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.

enter image description here

I need to resize the image to make it a bit smaller.

Is it possible with the current package?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

平生欢 2025-01-18 13:15:19

您可以使用内联 HTML 并提供大小。

<img src = "assets/images/image01.png" width="x" height="x" />

[<img src ="assets/images/image01.png" width="100" height="x"/> ](assets/images/image01.png)

更多和参考:在 Markdown 中更改图像大小

You can use inline HTML <img/> with providing size.

<img src = "assets/images/image01.png" width="x" height="x" />

Or

[<img src ="assets/images/image01.png" width="100" height="x"/> ](assets/images/image01.png)

More and ref: Changing image size in Markdown

友谊不毕业 2025-01-18 13:15:19
<img src="drawing.jpg" alt="drawing" width="200"/>

这是关于此的 github 讨论,https://gist.github.com/uupaa/f77d2bcf4dc7a294d109

<img src="drawing.jpg" alt="drawing" width="200"/>

This the github discussion on this, https://gist.github.com/uupaa/f77d2bcf4dc7a294d109

傲世九天 2025-01-18 13:15:19

当具体考虑 Flutter Markdown 插件 时,调整图像大小的一个好方法是使用 imageBuilder 参数。

对于您的示例,以下是返回 Markdown 小部件时调整图像大小的代码:

imageBuilder: (uri, title, alt) {
  return Image.asset(uri.path,width: 50,height: 50,);
},

对于其他情况(例如网络图像),您可以从名为 kDefaultImageBuilder 的默认函数中找到灵感 当未指定 imageBuilder 时:https://github.com/flutter/packages/blob/ec4a54604ff5043891bae98498116a714061baa5/packages/flutter_markdown/lib/src/_functions_io.dart#L18-L42

When 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:

imageBuilder: (uri, title, alt) {
  return Image.asset(uri.path,width: 50,height: 50,);
},

For other cases such as network images for example, you can find inspiration from the default function called, kDefaultImageBuilder when no imageBuilder is specified: https://github.com/flutter/packages/blob/ec4a54604ff5043891bae98498116a714061baa5/packages/flutter_markdown/lib/src/_functions_io.dart#L18-L42

想挽留 2025-01-18 13:15:19

您可以使用 Flutter Markdown 指定 URL 末尾的图像大小,如下所示:

![Image](https://link.to/image.png#80x50)

这会将图像大小调整为宽度 80 像素、高度 50 像素

You can specify the size of the image at the end of the URL using Flutter Markdown like this :

![Image](https://link.to/image.png#80x50)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文