[cross_file] Add runnable example with main()#11527
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the cross_file package example by adding a runnable main entry point and a demonstration of XFile.fromData for in-memory byte construction. Corresponding tests were added to verify the new functionality. Feedback includes removing redundant type arguments in the byte list initialization and wrapping the disk-based file instantiation in a try-catch block to improve robustness across platforms like the web.
9d29218 to
afb5116
Compare
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
We want examples to be easily discoverable by users, and also to show up on pub.dev, so a main entry point for an example should be in lib/main.dart. If we only need one file, the file should be renamed.
|
@stuartmorgan-g I was caught up with another PR. Will address the feedback this week. |
|
@stuartmorgan-g, is there any update to this issue? LMK if there's any feedback. |
|
@bparrishMines, can you please add the CICD label again? |
|
@bparrishMines fixed the failed readme snippet validation. Resolved the conflict. Please add the CICD label again. Thanks. |
|
@stuartmorgan-g For the final review |
…er#188916) flutter/packages@e742106...420e135 2026-07-02 dkwingsmt@users.noreply.github.com [material_ui] Migrate api sample code to @example dartdoc directive (flutter/packages#12078) 2026-07-02 dkwingsmt@users.noreply.github.com [material_ui] Move over more API samples (flutter/packages#12092) 2026-07-01 katelovett@google.com [cupertino_ui] Migrate api sample code to @example dartdoc directive (flutter/packages#12063) 2026-07-01 katelovett@google.com [cupertino_ui] Move over more API samples (flutter/packages#12086) 2026-07-01 48776784+mackings@users.noreply.github.com [two_dimensional_scrollables] Fix TreeView horizontal hit testing (flutter/packages#11859) 2026-07-01 1063596+reidbaker@users.noreply.github.com [camera_android_camerax][tool] Integrate dart_code_linter for cyclomatic complexity checks (flutter/packages#11999) 2026-07-01 dinurymomshad.dev@gmail.com [cross_file] Add runnable example with main() (flutter/packages#11527) 2026-07-01 36861262+QuncCccccc@users.noreply.github.com [cupertino_ui] Enable `switch_test.dart` (flutter/packages#12076) 2026-07-01 jmccandless@google.com [cupertino_ui] Re-enable dialog_test.dart (flutter/packages#12057) 2026-07-01 jmccandless@google.com [cupertino_ui] Re-enable action_sheet_test.dart (flutter/packages#12055) 2026-07-01 rmolivares@renzo-olivares.dev [cupertino_ui] Migrate `bottom_tab_bar_test.dart` to `SemanticsHandle` (flutter/packages#12012) 2026-07-01 1063596+reidbaker@users.noreply.github.com [repo] Add comment style guideline to AGENTS.md (flutter/packages#12077) 2026-07-01 43054281+camsim99@users.noreply.github.com Adds pre-push readiness skill (flutter/packages#11935) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com 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 main() entry point and an XFile.fromData demonstration to the cross_file example, so pub.dev's Pana scoring recognises that the package ships with an example.
The existing readme_excerpts.dart defined instantiateXFile() but had no top-level main(), so the file wasn't discovered as an example. This keeps the existing #docregion Instantiate block used by README.md and adds a second #docregion InstantiateFromData block alongside a main() that runs both excerpts.
The new test exercises XFile.fromData on every platform (the existing path-based test is skipped on web, which has no filesystem).
Fixes flutter/flutter#93073
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