getAssetsPathAfterData method

Future<String> getAssetsPathAfterData(
  1. String assetPath
)

Implementation

Future<String> getAssetsPathAfterData(String assetPath) async {
  final filePath = await _getCachePath(assetPath);
  final cacheData = await _getCacheData(assetPath);
  if (cacheData != null) {
    return filePath;
  }
  final byteData = await rootBundle.load(assetPath);
  final file = File(filePath);
  await file.create(recursive: true);
  await file.writeAsBytes(byteData.buffer.asUint8List());
  return file.path; // 返回本地物理路径
}