Repository navigation
[cross_file_web] Adds support to instantiate the web PlatformXFile without needing to import web apis - #13395
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for creating a WebScopedStorageXFile from bytes by introducing the WebScopedStorageXFileCreationParams.fromBytes factory constructor, updating the changelog, and adding integration tests. The review feedback suggests correcting a grammatical typo in the new constructor's documentation and expanding test coverage to verify behavior when fileName is null.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for creating a WebScopedStorageXFile from bytes on the web, along with a platform-safe entry point (cross_file_web_safe.dart) to prevent compilation failures on non-web platforms. It adds the WebScopedStorageXFileCreationParams.fromBytes constructor, corresponding stub implementations, integration tests, and updated documentation. Feedback on the changes suggests removing the const keyword from the fromBytes constructor in the safe stub to maintain compilation consistency with the non-const factory constructor in the actual web implementation.
davidmorgan
left a comment
There was a problem hiding this comment.
The approach of a web-safe library with a conditional export looks good. Two points on the non-web stub, as line comments, plus some smaller notes:
- The stub's
WebScopedStorageXFileclass is not exported bycross_file_web_safe.dart, which exports onlyWebScopedStorageXFileCreationParamsandWebScopedStorageXFileExtension, so roughly 60 lines of the stub look unreachable. Is it needed? - No test exercises the stub's behaviour: the integration tests run on web and so go through the real implementation, and
tests_exist_elsewhere_test.dartonly checks that the import compiles on the VM. - In the integration test, the import alias
web_safe_filerefers tosrc/web_scoped_storage_cross_file.dart, the web-only library, which reads as if it were the safe one. - Minor: the stub has no
fromObjectUrl, although that factory takes only aString; andtestOverridesis typeddynamic. Both may be deliberate.
Not verified: CI status, and compiling the first line comment's case on both platforms; that point rests on the language rule that a sealed class cannot be instantiated.
Since it's an API addition it looks like maybe @stuartmorgan-g should also take a look?
Piinks
left a comment
There was a problem hiding this comment.
+1 to all of @davidmorgan's comments above. Left a few additional non-overlapping notes below on exporting CrossFileWeb and fromObjectUrl from the safe library and how the download integration test can use the web_safe import directly.
I am also still new to this area and learning, let me know if I am off the mark on some of these points. :)
Since I removed safe
Ah I missed that. I assumed Dart files weren't allowed to import the same thing twice but it look like that adding an alias overrides that.
This is true, but I assumed that a user wouldn't have a String |
davidmorgan
left a comment
There was a problem hiding this comment.
The updates address the earlier comments: the stub params class is now sealed, both stub factories throw UnsupportedError, the unreachable stub WebScopedStorageXFile is gone, the VM test exercises the stub, and the integration test imports the safe library. LGTM, with one CHANGELOG nit inline.
| ## NEXT | ||
| ## 1.1.0 | ||
|
|
||
| * Adds support for creating a `WebScopedStorageXFile` that is cross-platform safe. See |
There was a problem hiding this comment.
Nit: since the stub WebScopedStorageXFile was removed, this now reads as if a safe WebScopedStorageXFile exists. Maybe something like: "Adds WebScopedStorageXFileCreationParams.fromBytes, and cross_file_web_safe.dart, a library that can be imported on all platforms to reference CrossFileWeb and the web creation params."
There was a problem hiding this comment.
Added a more comprehensive CHANGELOG.
…r#196296) flutter/packages@565c657...08faf64 2026-11-10 [email protected] [pigeon] Pass data classes and collections in a single buffer per native interop call (flutter/packages#13265) 2026-11-10 [email protected] [ci] Fix release workflows (flutter/packages#13611) 2026-11-09 [email protected] [pigeon] Fix standalone Native Interop @FlutterApi issues (flutter/packages#13609) 2026-11-09 [email protected] [cross_file_web] Adds support to instantiate the web PlatformXFile without needing to import web apis (flutter/packages#13395) 2026-11-09 [email protected] Sync release-go_router-18.1.4 to main (flutter/packages#13606) 2026-11-09 [email protected] Sync release-material_ui-1.11.0 to main (flutter/packages#13605) 2026-11-09 [email protected] [vector_graphics_compiler] Resolve Flutter artifact cache via package:cli_util (flutter/packages#13252) 2026-11-09 [email protected] [ci] Remove `pull_request_target` workflows (flutter/packages#13581) 2026-11-09 [email protected] Roll Flutter from acade0f to d463821 (1 revision) (flutter/packages#13601) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Adds a
fromBytestoWebScopedStorageXFileCreationParamssoXFilecan be instantiated without needing to import web APIs likefromBlob.Adds a
cross_file_web_safe.dartlibrary that importsweb_scoped_storage_cross_file_safe.dartwhen not compiling on web.Pre-Review Checklist
[shared_preferences]///).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