getFile static method
- String path
Returns a "safe" File from a given path.
iOS sometimes changes the path of its standard app folders, like the one we use in getDirectory. With this method we refresh the path for iOS. cf. https://github.com/openfoodfacts/smooth-app/issues/4725
Implementation
static Future<File> getFile(String path) async {
if (Platform.isIOS) {
final int lastSeparator = path.lastIndexOf('/');
final String filename = lastSeparator == -1
? path
: path.substring(lastSeparator + 1);
final Directory directory = await getDirectory();
path = '${directory.path}/$filename';
}
return File(path);
}