Open sowens-csd opened 3 years ago
@sowens-csd I had the same issue and had to check out the example for a little help. This worked for me.
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart' as c;
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
class IOFileSystem implements c.FileSystem {
final Future<Directory> _fileDir;
IOFileSystem(String key) : _fileDir = createDirectory(key);
static Future<Directory> createDirectory(String key) async {
var baseDir = await getTemporaryDirectory();
var path = p.join(baseDir.path, key);
var fs = const LocalFileSystem();
var directory = fs.directory((path));
await directory.create(recursive: true);
return directory;
}
@override
Future<File> createFile(String name) async {
assert(name != null);
return (await _fileDir).childFile(name);
}
}
I see that IOFileSystem is not exported by the package, so that could be it.
However, IOFileSystem(key),
is the default so that is not customising anything. The example of @sethchhim gives you more options to customise, for example the base path of where the images are stored.
Excellent, if that's the default then I don't need it. You can probably remove that from the sample in your README but I see you have a doc label so you were likely planning to do that.
Just in case I need to customize it in the future, should it be exported by the package?
I think so, but I'll have to try it.
@renefloor do you plan to export IOFileSystem? @sethchhim 's workaround is okay but temporary for me (it is a duplicated code with warning "Don't import implementation files from another package")...
@renefloor Until file_system.dart
is included in exported files, custom implementations are only possible by importing internal dependencies, which is bad practice. Any plans for exporting FileSystem
?
+1 for this, we can't properly customize the fileSystem
class as of now. Also, it would be great if we could somehow affect the directory of the "cached" files (i.e ApplicationsDirectory
instead of CacheDirectory
, so we don't need to subclass and overwrite existing logic.
Any update? how to fix this?
I'm upgrading from the previous version to 2.0.0 and trying to follow the new Customize instructions to use CacheManager instead of BaseCacheManager. The reference to IOFileSystem doesn't resolve. What am I doing wrong?