cacheFor static method
Static method for Dynamic call
Implementation
// Request to `cache` the Granted Directory into App's Package [files] folder
static Future<List<String>?> cacheFor(String? directory,
{String fileType = "any"}) async {
if (directory == null) return null;
try {
const kCacheToExternalFilesDirectory = "cacheToExternalFilesDirectory";
const kSourceTreeUriString = "sourceTreeUriString";
const kFileType = "fileType";
const kCacheDirectoryName = "cacheDirectoryName";
var cacheDirectoryName = makeDirectoryPathToName(directory);
var uriString = makeUriString(path: directory, isTreeUri: true);
final args = <String, dynamic>{
kSourceTreeUriString: uriString,
kFileType: fileType,
kCacheDirectoryName: cacheDirectoryName,
};
final paths = await kDocumentFileChannel.invokeMethod<List<dynamic>?>(
kCacheToExternalFilesDirectory, args);
if (paths == null) return null;
return List<String>.from(paths);
} catch (e) {
return null;
}
}