【发布时间】:2019-01-31 07:01:23
【问题描述】:
我有以下代码将我的背景图片设置为资产图片:
Container(
decoration: new BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg.png"),
)
),
我想知道我之前是否将图像存储到设备中,如何将其用作背景图像?
Future<File> _getLocalFile(String filename) async {
String dir = (await getApplicationDocumentsDirectory()).path;
File f = new File('$dir/$filename');
return f;
}
谢谢。
【问题讨论】:
-
您可以使用
SharedPreferences来跟踪您是否保存了上一张图片,然后执行您需要的操作。 -
我确定图像已保存,但我如何访问它 - 我尝试使用 Image.file 但说我无法将 Image 转换为 ImageProvider
-
在这种情况下使用
FileImage。 -
谢谢,不知道 FileImage 类。