flutter_html
flutter_html copied to clipboard
[BUG] ImageExtension builder is not executed when the image source is relative path
Describe the bug: How to set base url correctly for relative path images?
HTML to reproduce the issue:
Html(
data: '<img width="10" alt="xkcd" src="/comics/commemorative_plaque.png" />',
onLinkTap: _launchUrl,
style: {
'img': Style(
width: Width(175),
),
},
extensions: [
ImageExtension(
handleAssetImages: false,
handleDataImages: false,
builder: (ctx) {
return Image.network('https://imgs.xkcd.com${ctx.attributes['src']}');
},
),
],
)
Expected behavior: image should be shown
Device details and Flutter/Dart/flutter_html
versions:
3.0.0-beta.2
https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#customimagerenders might help you. You can use
builder: (extensionContext) {
final element = extensionContext.styledElement as ImageElement;
return CustomImage.network(
"https://imgs.xkcd.com/${element.src}$",
);
}
https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#customimagerenders might help you. You can use
builder: (extensionContext) { final element = extensionContext.styledElement as ImageElement; return CustomImage.network( "https://imgs.xkcd.com/${element.src}$", ); }
From where do I import CustomImage ?
https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#customimagerenders might help you. You can use
builder: (extensionContext) { final element = extensionContext.styledElement as ImageElement; return CustomImage.network( "https://imgs.xkcd.com/${element.src}$", ); }
From where do I import CustomImage ?
never mind :)
https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#customimagerenders可能对您有帮助。您可以使用
builder: (extensionContext) { final element = extensionContext.styledElement as ImageElement; return CustomImage.network( "https://imgs.xkcd.com/${element.src}$", ); }
从哪里导入CustomImage?
import 'package:flutter_html/src/tree/image_element.dart';