Rah*_*hul 8 caching image cache-control flutter
这是我的用例:
我们的应用程序也可以离线使用。我尝试了一些类似的库flutter_advanced_networkimage,flutter_cache_manager但我遇到了相当大的延迟,而且大多数时候应用程序崩溃了。
Swi*_*ter 17
将其保存在您的应用程序的临时目录中:
import 'dart:io';
// https://pub.dev/packages/path_provider
import 'package:path_provider/path_provider.dart';
final Directory temp = await getTemporaryDirectory();
final File imageFile = File('${temp.path}/images/someImageFile.png');
if (await imageFile.exists()) {
// Use the cached images if it exists
} else {
// Image doesn't exist in cache
await imageFile.create(recursive: true);
// Download the image and write to above file
...
}
Run Code Online (Sandbox Code Playgroud)
它将在应用程序启动时持续存在,并且只有在用户亲自清除缓存或重新安装应用程序时才会被删除。
| 归档时间: |
|
| 查看次数: |
9096 次 |
| 最近记录: |