我想将路径“content://media/external/images/media/138501”转换为文件并在图像中设置。
代码:
File imageFile = File("content://media/external/images/media/138501");
Run Code Online (Sandbox Code Playgroud)
不工作:
DecorationImage(image: ExactAssetImage(imageFile.path),fit: BoxFit.fill)
Run Code Online (Sandbox Code Playgroud)
Psy*_*hoX -1
您可以使用Image.file构造函数。
DecorationImage(
image: Image.file(File("content://media/external/images/media/138501")),
fit: BoxFit.fill
)
Run Code Online (Sandbox Code Playgroud)
请注意:在 Android 上,这可能需要许可android.permission.READ_EXTERNAL_STORAGE。
| 归档时间: |
|
| 查看次数: |
6941 次 |
| 最近记录: |