Open renefloor opened 4 years ago
FWIW I have also successfully used MemoryFileSystem
on the web. I agree that the pub tagging could work better, but I don't really have a better alternative. Ultimately File
, Directory
, FileSystemEntity
are already interfaces, and they do have web implementations (though these throw by default). Updating this package to create it's own separate file types would be massively breaking and doesn't seem to buy us much besides working around the pub logic.
FYI @mit-mit
Does exist FileSystem implementation for storing data permanently in Web? It's possible to use for example LocalStorage to IndexedDb.
Web is still in beta, but I'm trying to make my packages compatible with web. As a first quick fix for flutter_cache_manager I made use of the MemoryFileSystem to save the files and don't need any changes. This works perfectly as a temporary memory cache, but I can't get a 'web' badge on pub.
The problem is that 'File' of this package implements 'io.File'. Really the only reference to 'dart:io' is that interface. At least File has a counterpart in dart:html, so maybe we can create a conditional import for that, but Directory doesn't have a counterpart. The ideal solution would be to make a generic interface (abstract class) in the dart engine which is implemented by the abstract io.File. However, that would need everybody to use the generic File interface instead of the io interface. It wouldn't really break anything though when people still use the io.File as long as they don't use flutter_cache_manager for example which would use the generic one.
This is a pretty big change for relatively little effect (mainly the badge, because it already works on the web). So I mainly want your opinion whether it is worth it to create a proposal and really make such a change. If you have any other ideas how to fix this it that would also be appreciated.