-
Notifications
You must be signed in to change notification settings - Fork 30.6k
[cross_file] Platform-aware factories. #91869
Copy link
Copy link
Open
flutter/packages
#11010Labels
📜Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")P2Important issues not at the top of the work listImportant issues not at the top of the work listc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilitydesign docTracks a design discussion documentTracks a design discussion documentp: cross_fileThe cross_file pluginThe cross_file pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Metadata
Metadata
Assignees
Labels
📜Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")Issue was posted to Discord. Remove to have the issue reannounced. (For "design doc", "emergency")P2Important issues not at the top of the work listImportant issues not at the top of the work listc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilitydesign docTracks a design discussion documentTracks a design discussion documentp: cross_fileThe cross_file pluginThe cross_file pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Type
Fields
Give feedbackNo fields configured for issues without a type.
The current implementation of
cross_filerelies 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:iois available, they could do:XFileIO.fromFile(io.File file)orXFileIO.fromPath(String path)But if
dart:htmlis availableXFileWeb.fromHtmlFile(html.File file)orXFileWeb.fromBlob(html.Blob blob, String name)orXFileWeb.fromBlobUrl(String blobUrl, String name, int length...)...or any other "specialty" constructors that would make sense per platform.
The
XFileclass 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
XFileas the base-class name for all the objects, instead of being the top-most classname, which is weird from an OOP standpoint!)Some questions: