[cross_file] Updates cross_file to a package separated federated plugin #11010
[cross_file] Updates cross_file to a package separated federated plugin #11010bparrishMines wants to merge 362 commits into
Conversation
| assets: | ||
| - assets/hello.txt | ||
|
|
||
| dependency_overrides: |
There was a problem hiding this comment.
Why is this an override and not the actual dependency?
|
|
||
| /// The common superclass for [XFile] and [XDirectory]. | ||
| @immutable | ||
| class XEntity { |
There was a problem hiding this comment.
Should this maybe XFilesystemEntity to make it clearer what it's for and less likely to collide with other things? That would also be consistent with the Dart IO class names.
| @internal | ||
| final PlatformXEntity platform; | ||
|
|
||
| /// A string used to reference the resource's location. |
There was a problem hiding this comment.
Nit: "identifier" rather than "location", since we are using the term "uri".
| /// Provides a nonnull platform class extension. | ||
| /// | ||
| /// Will throw an exception if the specified platform extension can not be | ||
| /// returned. |
There was a problem hiding this comment.
I've been thinking about this more; under what circumstances would this be safe to call? It's up to the platform implementation what extension (if any) to return, and that's an implementation detail of the platform, so clients shouldn't rely on knowing it.
Should we just have S? getExtension?
| /// the resource. | ||
| Future<Uint8List> readAsBytes() => platform.readAsBytes(); | ||
|
|
||
| /// Reads the entire resource contents as a string using the given Encoding. |
| @override | ||
| Stream<Uint8List> openRead([int? start, int? end]) { | ||
| assert(start == null || start >= 0); | ||
| assert(end == null || end >= (start ?? 0)); |
There was a problem hiding this comment.
Don't these need to throw ArgumentError, rather than just assert in debug?
| void dataReceivedHandler(NSData data) { | ||
| final Uint8List bytes = _extractBytesToUint8List(data); | ||
|
|
||
| runOnPlatformThread(() { |
There was a problem hiding this comment.
TODO to remove these once thread merging is non-optional on macOS?
There was a problem hiding this comment.
Actually, wait, does this code work on macOS without thread merging? It looks like this is being used to make the Dart code run on the Dart main isolate's thread, which isn't going to be the platform thread in that case.
Maybe we can't implement this code with FFI yet after all?
There was a problem hiding this comment.
Please add a CONTRIBUTING.md explaining the use of this, as in path_provider_foundation.
| `XFile` on the web platform is backed by [Blob](https://api.dart.dev/be/180361/dart-html/Blob-class.html) | ||
| objects and their URLs. | ||
|
|
||
| It seems that Safari hangs when reading Blobs larger than 4GB (your app will stop without returning |
There was a problem hiding this comment.
Isn't this (and the related next paragraph) no longer applicable to this version of the package?
|
|
||
| [](https://caniuse.com/bloburls) | ||
|
|
||
| ### Tests |
There was a problem hiding this comment.
This should move to a CONTRIBING.md
Updates
cross_fileto a package separated federated plugin.Keeping the package separation is still debatable.Follows the general design outlined at https://flutter.dev/go/flutter-file-system
Fixes flutter/flutter#91869
Implementation is split into
dart:io(all platforms except Web)package:webFiles (subclass ofBlob.Pubspec dependencies have been changed to use ones from git to have runnable example apps while in development and review. Specifically because
file_selectoruses the current version of cross_file and I didn't want to make this a file_selector + cross_file PR. Can update it to this if preferred.The reason
file_selectoris different for the example apps is because I wanted to ensue Android, iOS, macOS still work without copying the file to a file with the Apps sandbox.Example
The
cross_fileexample will run for all platforms.Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3