首页 > 解决方案 > 如何在从本机android访问颤振资源时将键字符串转换为可绘制(int)

问题描述

我正在尝试从我的根文件夹中访问图像。

在根文件夹中,我有

assets
    test.jpeg

我还包含在我的pubspec.yaml

flutter:
assets:
- assets/test.jpeg

现在在我的java代码中,我有这个:

FlutterLoader loader = FlutterInjector.instance().flutterLoader();
String key = loader.getLookupKeyForAsset("assets/test.jpeg");

现在,基于此:我需要 decodeResources 将 Integer 作为参数

Bitmap bmp = BitmapFactory.decodeResource(mContext.getResources(), what will I put here...);

在android中我可以这样做:

Bitmap bmp = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.test.jpeg);

基于这个答案here

标签: javaandroidflutterandroid-resources

解决方案


推荐阅读