getFileBytes function

Future<Uint8List?> getFileBytes(
  1. String url
)

判断是否有对应图片缓存文件存在

Implementation

Future<Uint8List?> getFileBytes(String url) async {
  String cacheDirPath = await getCachePath();

  String urlMd5 = getUrlMd5(url);
//  return await compute(_getFileBytes,"$cacheDirPath/$urlMd5");
  File file = File("$cacheDirPath/$urlMd5");

  try{
    return await file.readAsBytes();
  }catch(e){
    //ignore
  }
  return null;
}