binding.getFlutterAssets().getAssetFilePathByName('xxxx')得到的是资源路径,加载原生图片资源可以参考如下代码:
@State imageSource:image.ImageSource|null=null
async aboutToAppear()
{
let args: HashMap<string, object | string> = this.viewManager.args as HashMap<string, object>
this.image = args.get('src') as string
let rmg = DemoPluginAssetPlugin.binding.getApplicationContext().resourceManager;
let rawfile = await rmg.getRawFileContent("flutter_assets/"+this.image );
let buffer = rawfile.buffer.slice(0);
this.imageSource = image.createImageSource(buffer);
}
build() {
Column(){
if(this.imageSource){
Image(this.imageSource.createPixelMapSync())
}
}
}