assetImageRender function
Implementation
ImageRender assetImageRender({
double? width,
double? height,
}) =>
(context, attributes, element) {
final assetPath = _src(attributes)!.replaceFirst('asset:', '');
if (_src(attributes)!.endsWith(".svg")) {
return SvgPicture.asset(assetPath, width: width ?? _width(attributes), height: height ?? _height(attributes));
} else {
return Image.asset(
assetPath,
width: width ?? _width(attributes),
height: height ?? _height(attributes),
frameBuilder: (ctx, child, frame, _) {
if (frame == null) {
return Text(_alt(attributes) ?? "", style: context.style.generateTextStyle());
}
return child;
},
);
}
};