Repository navigation
Description
The current implementation of cross_file relies on cross-platform constructors that "need to work" across all platforms. With time, and as features are added, these constructors end up growing, and now some parameters are being ignored by some platforms and used by others. This causes confusion/problems.
It seems that cross-platform constructors are not the way to go for this particular package; instead XFile users should be able to choose what factory they need for the platform that they're implementing. So, in places where dart:io is available, they could do:
XFileIO.fromFile(io.File file) or XFileIO.fromPath(String path)
But if dart:html is available
XFileWeb.fromHtmlFile(html.File file) or XFileWeb.fromBlob(html.Blob blob, String name) or XFileWeb.fromBlobUrl(String blobUrl, String name, int length...)...
or any other "specialty" constructors that would make sense per platform.
The XFile class that most people use would end up being a read-only interface to retrieve data from the file, and the different backing implementations would extend it.
(This would also allow us to return XFile as the base-class name for all the objects, instead of being the top-most classname, which is weird from an OOP standpoint!)
Some questions:
- What to do when the user wants to modify the contents of a file programmatically?
- How to perform those operations so the modified file still uses an efficient backend?
- Should we keep an "inefficient" Uint8List-backed constructor so people can build raw files from memory?
Activity
ditman commentedon Oct 15, 2021
Jjagg commentedon Dec 30, 2021
I ran into a pretty serious limitation caused by this issue.
Because
XFiledoes not have aBlobconstructor for web, it can't refer to a file on the user's machine. And without aBlob, there's no way to get the data in the file back from theXFile. So, currently, the only way to pass the file data in anXFileis by reading the full file into memory and passing theUint8Listin the constructor.I ran into this with a drag and drop implementation for web.
ditman commentedon Jan 5, 2022
@Jjagg yes, having a
Blobconstructor on the web is my main motivation for this change. The current web version loads a file, internally stores its blob URL, and then it attempts to re-hydrate the Blob when reading data from it. It should just... store the File/Blob and be done with it.22 remaining items
flutter-triage-bot commentedon Aug 14, 2026
This design doc is assigned to @bparrishMines but has had no recent status updates. If the proposal has been deferred, please consider unassigning thes issue. Alternatively, if the design doc has been abandoned, please close the issue. This allows people to have a clearer picture of what work is actually planned. Thanks!
bparrishMines commentedon Aug 20, 2026
This is still being worked on in flutter/packages#11010
[cross_file] Move cross_file into a federated cross_file directory (#…
[cross_file_io] `dart:io` implementation of cross_file (#12876)
[cross_file_android] Android implementation of `cross_file` (#12909)
[cross_file_web] Web implementation of `cross_file` (#12908)
[cross_file_darwin] iOS/macOS implementation of `cross_file` (#12910)
[cross_file] Updates cross_file to a package separated federated plug…
github-actions commentedon Oct 8, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.