render static method
AssetImage
render(
- String nameOrAlias, {
- bool isProjectImage = false,
- OnImageWidgetConfig? imageConfig,
渲染asset图片
nameOrAlias
通过名称或别名查找全路径
isProjectImage
当为项目本身工程下图时以相对路径提供,避免部分图片转换Uint8List失败问题
imageConfig
图片配置对象
Implementation
static AssetImage render(String nameOrAlias, {bool isProjectImage = false, OnImageWidgetConfig? imageConfig}) {
var imageFactory = ConfigManager.instance.getConfig(ImageKey.imageListKey);
if (imageFactory is! ImageListFactory) {
return AssetImage(imageConfig?.onDefaultImage() ?? "");
}
ImageListFactory imageListFactory = imageFactory;
String alias = nameOrAlias.withoutExtension;
ImageResponse? response = imageListFactory.getFlutterImageResponse(alias);
if (response == null) {
return AssetImage(imageConfig?.onDefaultImage() ?? "");
}
if (isProjectImage) {
return AssetImage(response.relative ?? "");
} else {
return AssetImage(response.result ?? "");
}
}