Skip to content

docs: move fillRandomBytes example to a separate file - #354

Open
LALITH0110 wants to merge 1 commit into
google:masterfrom
LALITH0110:docs-move-random-example
Open

docs: move fillRandomBytes example to a separate file#354
LALITH0110 wants to merge 1 commit into
google:masterfrom
LALITH0110:docs-move-random-example

Conversation

@LALITH0110

Copy link
Copy Markdown

Towards #283 — one primitive per PR, as requested in the issue.

Moves the fillRandomBytes example out of its dartdoc comment and into example/webcrypto/random/fill_random_bytes.dart, referenced with {@example /example/webcrypto/random/fill_random_bytes.dart#example}. This follows the shape of #293 (HMAC importRawKey).

The example code itself is unchanged from what the docs already showed — it was copied verbatim. The only additions are the license header, the #region/#endregion markers, and one ignore_for_file.

Note on avoid_print

The example prints its result, and example/webcrypto/ is not excluded from analysis, so flutter_lints' avoid_print fires on it once the code leaves the doc comment. I've added // ignore_for_file: avoid_print rather than change what the example demonstrates, since printing the random bytes is the point of it.

Happy to drop the print and the ignore instead if you'd prefer examples to be lint-clean without suppressions — that would mean the rendered docs differ slightly from today's.

Verification

Run with Dart 3.12.2 (the repo requires ^3.10.0):

  • dart analyze example/webcrypto libNo issues found
  • dart format --output=none --set-exit-if-changed on both changed files → 0 changed
  • Removed the ignore_for_file line temporarily to confirm the suppression is actually load-bearing → avoid_print fires, as expected
  • Diffed the extracted example against the original doc comment → identical

AI disclosure: this change was drafted with AI assistance. I reviewed it, and the verification above (including the negative test for the lint suppression) was run locally before opening the PR.

Moves the `fillRandomBytes` dartdoc example into
`example/webcrypto/random/fill_random_bytes.dart` and references it with
`{@example ...}`, so the example is covered by `dart analyze` and
`dart format` instead of living inside a doc comment.

The example code is unchanged from what the documentation already showed.
`avoid_print` is suppressed for the file because the example prints its
result, matching how the docs demonstrate it.

Towards google#283
@google-cla

google-cla Bot commented Aug 1, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@LALITH0110

Copy link
Copy Markdown
Author

@googlebot I signed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant