-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] [cross_file] New architecture. #7591
base: main
Are you sure you want to change the base?
Conversation
/cc @stuartmorgan this is my idea for the "next" version of the x-files. PTAL and let me know what you think, or if you want this to go in another direction :) |
|
||
@override | ||
Future<void> saveTo(String path) async { | ||
final File fileToSave = File(path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is lifted from the old implementation but... should the File
be created from path + this.name
?
packages/cross_file/lib/src/implementations/web_bytes_x_file.dart
Outdated
Show resolved
Hide resolved
|
||
/// A CrossFile backed by a dart:io [File]. | ||
/// | ||
/// (Mobile-only). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget desktop :)
/// (Mobile-only). | |
/// This is only supported on non-web platforms. |
/// The [path] variable is ignored. | ||
@override | ||
Future<void> saveTo(String path) async { | ||
// Save a Blob to file... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems a bit redundant.
objects and their URLs. | ||
|
||
It seems that Safari hangs when reading Blobs larger than 4GB (your app will stop | ||
without returning any data, or throwing an exception). | ||
|
||
This package will attempt to throw an `Exception` before a large file is accessed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure, was this comment removed, because we now refer to the browser's behavior? Or was this fixed in recent versions of Safari?
|
||
Example: | ||
In order to instantiate a new `XFile`, import the correct factory class, | ||
either from `package:cross_file/native/factory.dart` (for native development) or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small drive-by comment:
Since the two implementations now have platform-specific imports (dart:io or package:web)
users who take the imports at face value might run into compilation issues, because they lack a conditional import?
Can we provide guidance on how to avoid this? With the legacy API we had the File or Blob types as internals and not on the public interface, which allowed for the plugin to provide a conditional import shim.
Quick note to say I haven't forgotten about this, I just haven't had time to fully context switch to give this the attention it will need. I'll try to do it within the next week. |
This PR attempts to solve the current issues of
XFile
by slightly re-architecting it.In this PR:
XFile
is now an interface that does not have any code, except for the two "legacy" constructors that are maintained (but deprecated) for backwards-compatibility reasons.XFile
instances are now created from the platform-specific (native
vsweb
) factories.This does not remove
saveAs
from theXFile
interface.Note
This is a breaking change because I've made the oldXFile
constructors deprecated (and throwy) but if we want to, we could possibly re-implement the "old" constructors with the new implementations and a few conditional imports?This is not a breaking change anymore. Old tests continue passing (
test/legacy*
), and new tests contain minor changes.Anyway, just a RFC!
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.