fetchToMemory method
Implementation
Future<Uri> fetchToMemory(String fileName) async {
if (kIsWeb) {
final uri = _sanitizeURLForWeb(fileName);
// We rely on browser caching here. Once the browser downloads this file,
// the native side implementation should be able to access it from cache.
await http.get(uri);
return uri;
}
// read local asset from rootBundle
final byteData = await loadAsset('$prefix$fileName');
// create a temporary file on the device to be read by the native side
final file = fileSystem.file('${await getTempDir()}/$cacheId/$fileName');
await file.create(recursive: true);
await file.writeAsBytes(byteData.buffer.asUint8List());
// returns the local file uri
return file.uri;
}