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?
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?
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
<img src="drawing.jpg" alt="drawing" width="200"/>
This the github discussion on this, https://gist.github.com/uupaa/f77d2bcf4dc7a294d109
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