Skip to content

[cupertino_ui] Migrate api sample code to @example dartdoc directive#12063

Merged
auto-submit[bot] merged 7 commits into
flutter:mainfrom
Piinks:cupertinoApiCode
Jul 1, 2026
Merged

[cupertino_ui] Migrate api sample code to @example dartdoc directive#12063
auto-submit[bot] merged 7 commits into
flutter:mainfrom
Piinks:cupertinoApiCode

Conversation

@Piinks

@Piinks Piinks commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Migrates @tool directives to @example in cupertino_ui
Towards flutter/flutter#172936 and flutter/flutter#172937

Referenced: https://github.com/flutter/packages/pull/11975/files

Pre-Review Checklist

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-assist bot 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

  1. 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

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 29, 2026
@github-actions github-actions Bot added triage-framework Should be looked at in framework triage p: cupertino_ui labels Jun 29, 2026
@Piinks Piinks changed the title Migrate Cupertino api code to @example dartdoc directive [cupertino_ui] Migrate api sample code to @example dartdoc directive Jun 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces {@tool dartpad} and {@tool snippet} blocks with {@example} directives across various Cupertino widgets, adds temporary TODO comments, and configures analysis_options.yaml to ignore doc_directive_unknown warnings. The feedback points out that using // instead of /// for the TODO comments breaks the contiguous doc comment blocks, which will cause the main widget descriptions to be omitted from the generated API documentation. Additionally, the reviewer notes that the paths in the {@example} directives should be relative to the package root by removing the leading slash.

Comment on lines +24 to +31
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows how [CupertinoActivityIndicator] can be customized.
///
/// ** See code in examples/api/lib/cupertino/activity_indicator/cupertino_activity_indicator.0.dart **
/// {@end-tool}
/// {@example /example/lib/activity_indicator/cupertino_activity_indicator.0.dart}
///
// TODO(dkwingsmt): End of the blue example container.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In Dart, any line starting with // (instead of ///) breaks the contiguous block of doc comments. This causes the doc comment block before the // TODO to be detached from the class/member declaration, meaning the main description of the widget/class will be completely missing from the generated API documentation.

To prevent this, use /// for the TODO comments to keep the doc comment block contiguous. Additionally, the path in {@example} should be relative to the package root (e.g., example/lib/... instead of /example/lib/...), as a leading slash can cause resolution issues. This issue is present across almost all files in this PR and should be fixed everywhere.

Suggested change
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows how [CupertinoActivityIndicator] can be customized.
///
/// ** See code in examples/api/lib/cupertino/activity_indicator/cupertino_activity_indicator.0.dart **
/// {@end-tool}
/// {@example /example/lib/activity_indicator/cupertino_activity_indicator.0.dart}
///
// TODO(dkwingsmt): End of the blue example container.
/// TODO(dkwingsmt): Replace the following block with a blue example container
/// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows how [CupertinoActivityIndicator] can be customized.
///
/// {@example example/lib/activity_indicator/cupertino_activity_indicator.0.dart}
///
/// TODO(dkwingsmt): End of the blue example container.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be, but I think we want that anyways. There will be no blue box initially so the line break will distinguish the separation of the code block from the rest of the docs?

Comment on lines +207 to +214
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows how [CupertinoLinearActivityIndicator] can be customized.
///
/// ** See code in examples/api/lib/cupertino/activity_indicator/cupertino_linear_activity_indicator.0.dart **
/// {@end-tool}
/// {@example /example/lib/activity_indicator/cupertino_linear_activity_indicator.0.dart}
///
// TODO(dkwingsmt): End of the blue example container.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using // breaks the contiguous doc comment block, detaching the main description of CupertinoLinearActivityIndicator from its declaration. Use /// instead to keep the block contiguous, and remove the leading slash from the {@example} path.

Suggested change
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows how [CupertinoLinearActivityIndicator] can be customized.
///
/// ** See code in examples/api/lib/cupertino/activity_indicator/cupertino_linear_activity_indicator.0.dart **
/// {@end-tool}
/// {@example /example/lib/activity_indicator/cupertino_linear_activity_indicator.0.dart}
///
// TODO(dkwingsmt): End of the blue example container.
/// TODO(dkwingsmt): Replace the following block with a blue example container
/// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows how [CupertinoLinearActivityIndicator] can be customized.
///
/// {@example example/lib/activity_indicator/cupertino_linear_activity_indicator.0.dart}
///
/// TODO(dkwingsmt): End of the blue example container.

Comment thread packages/cupertino_ui/lib/src/app.dart Outdated
Comment on lines +70 to +73
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
// TODO(dkwingsmt): Add unit tests to this code snippet.
// https://github.com/flutter/flutter/issues/188530

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using // breaks the contiguous doc comment block, detaching the main description of CupertinoApp from its declaration. Use /// instead to keep the block contiguous.

/// TODO(dkwingsmt): Replace the following block with a blue example container
/// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
/// TODO(dkwingsmt): Add unit tests to this code snippet.
/// https://github.com/flutter/flutter/issues/188530

Comment thread packages/cupertino_ui/lib/src/app.dart Outdated
Comment on lines +92 to +97
// TODO(dkwingsmt): End of the blue example container.
///
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
// TODO(dkwingsmt): Add unit tests to this code snippet.
// https://github.com/flutter/flutter/issues/188530

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using // breaks the contiguous doc comment block. Use /// instead to keep the block contiguous.

/// TODO(dkwingsmt): End of the blue example container.
///
/// TODO(dkwingsmt): Replace the following block with a blue example container
/// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
/// TODO(dkwingsmt): Add unit tests to this code snippet.
/// https://github.com/flutter/flutter/issues/188530

Comment on lines +49 to +56
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows a [CupertinoTabBar] placed in a [CupertinoTabScaffold].
///
/// ** See code in examples/api/lib/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart **
/// {@end-tool}
/// {@example /example/lib/bottom_tab_bar/cupertino_tab_bar.0.dart}
///
// TODO(dkwingsmt): End of the blue example container.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using // breaks the contiguous doc comment block, detaching the main description of CupertinoTabBar from its declaration. Use /// instead to keep the block contiguous, and remove the leading slash from the {@example} path.

/// TODO(dkwingsmt): Replace the following block with a blue example container
/// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows a [CupertinoTabBar] placed in a [CupertinoTabScaffold].
///
/// {@example example/lib/bottom_tab_bar/cupertino_tab_bar.0.dart}
///
/// TODO(dkwingsmt): End of the blue example container.

Comment on lines +61 to +69
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This sample shows produces an enabled and disabled [CupertinoButton] and
/// [CupertinoButton.filled].
///
/// ** See code in examples/api/lib/cupertino/button/cupertino_button.0.dart **
/// {@end-tool}
/// {@example /example/lib/button/cupertino_button.0.dart}
///
// TODO(dkwingsmt): End of the blue example container.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using // breaks the contiguous doc comment block, detaching the main description of CupertinoButton from its declaration. Use /// instead to keep the block contiguous, and remove the leading slash from the {@example} path.

/// TODO(dkwingsmt): Replace the following block with a blue example container
/// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This sample shows produces an enabled and disabled [CupertinoButton] and
/// [CupertinoButton.filled].
///
/// {@example example/lib/button/cupertino_button.0.dart}
///
/// TODO(dkwingsmt): End of the blue example container.

@Piinks Piinks requested review from dkwingsmt and justinmc June 29, 2026 23:26

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good minus my comment about distinguishing dartpad blocks. And I think Gemini is wrong about its double slash concern?

Comment on lines +24 to +25
/// {@tool dartpad}
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need a TODO that's different for dartpad vs. snippet, so that we can distinguish them later when we put the dartpads back. See discussion here: #11975 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good call! Let me update marking which ones were dartpads. 👍

Comment on lines +24 to +31
// TODO(dkwingsmt): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4243
///
/// This example shows how [CupertinoActivityIndicator] can be customized.
///
/// ** See code in examples/api/lib/cupertino/activity_indicator/cupertino_activity_indicator.0.dart **
/// {@end-tool}
/// {@example /example/lib/activity_indicator/cupertino_activity_indicator.0.dart}
///
// TODO(dkwingsmt): End of the blue example container.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that true?

@Piinks Piinks force-pushed the cupertinoApiCode branch from a7d3e82 to be5aa6e Compare June 30, 2026 15:39
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 30, 2026
@Piinks Piinks requested a review from justinmc June 30, 2026 16:49

@dkwingsmt dkwingsmt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for some minor places. Thank you Kate for working on this!


On a stricter note: While the current resolution for dartpads are

// TODO: Migrate the following block to dartpad
/// ...
// TODO: end of dartpad

My guess is that the following way is closer to the eventual format, hence slightly easier for the future migration:

// TODO: Start of blue container
/// ...
// TODO: Migrate the following directive to dartpad
/// ...
// TODO: end of blue container

However, this is no big deal. It's just a global find-and-replace away and we can still do it when we actually migrate to the blue containers. We should proceed with the current way to unblock the first release.

// `_SlideTarget`s.
//
// TODO(dkwingsmt): It should recompute hit testing when the app is updated,
// TODO(framework): It should recompute hit testing when the app is updated,

@dkwingsmt dkwingsmt Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unintentional change? Reverting:

Suggested change
// TODO(framework): It should recompute hit testing when the app is updated,
// TODO(dkwingsmt): It should recompute hit testing when the app is updated,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok! I guess I felt odd making all these TODOs yours. :)

Comment thread analysis_options.yaml Outdated

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@dkwingsmt dkwingsmt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue link in the dartpad TODOs should be changed to https://github.com/dart-lang/dartdoc/issues/4123

///
/// This sample demonstrates how to use [CupertinoTextMagnifier].
///
/// ** See code in examples/api/lib/widgets/magnifier/cupertino_text_magnifier.0.dart **

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a widgets example, I think I need to bring this sample code over. FYI @dkwingsmt we should check that there aren't samples from the widgets/* or other libraries in the material_ui version of this.

///
/// This sample demonstrates how to use [CupertinoMagnifier].
///
/// ** See code in examples/api/lib/widgets/magnifier/cupertino_magnifier.0.dart **

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too

///
/// This sample demonstrates how to customize the magnifier that this text field uses.
///
/// ** See code in examples/api/lib/widgets/text_magnifier/text_magnifier.0.dart **

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too

@Piinks

Piinks commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Added missing samples in #12086. I'll push a PR in flutter/flutter as well to keep sync.

@dkwingsmt dkwingsmt self-requested a review July 1, 2026 21:05
@justinmc justinmc added the CICD Run CI/CD label Jul 1, 2026
@dkwingsmt

Copy link
Copy Markdown
Contributor

@Piinks Can you address #12063 (review) ?

@Piinks

Piinks commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@Piinks Can you address (earlier review) ?

Yup, I already did, I just haven't pushed it yet because I need to add the missing samples as well from #12086

@Piinks

Piinks commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Which just merged! 🎊 Updating now

@dkwingsmt dkwingsmt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, menu_anchor.dart contains the only two instances of @tool sample. I've linked how they should be converted.

/// [CupertinoColors.systemRed].
///
/// {@tool sample}
// TODO(framework): Replace the following block with a @dartpad directive

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

///
/// ## Usage
/// {@tool sample}
// TODO(framework): Replace the following block with a @dartpad directive

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Piinks

Piinks commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Ah shoot, I think when I did a find and replace to update the dart issue links, I replaced ones I did not mean to.
@dkwingsmt can you confirm - dart-lang/dartdoc#4123 is for dartpad and dart-lang/dartdoc#4243 should be for the blue container ones?

@Piinks

Piinks commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

can you confirm - dart-lang/dartdoc#4123 is for dartpad and dart-lang/dartdoc#4243 should be for the blue container ones?

I am pretty sure I am right. Updating.

@dkwingsmt

Copy link
Copy Markdown
Contributor

Ah shoot, I think when I did a find and replace to update the dart issue links, I replaced ones I did not mean to. @dkwingsmt can you confirm - dart-lang/dartdoc#4123 is for dartpad and dart-lang/dartdoc#4243 should be for the blue container ones?

Yes, the issues are right.

Comment thread packages/cupertino_ui/lib/src/app.dart Outdated
///
/// {@tool snippet}
// TODO(framework): Replace the following block with a blue example container
// when it's supported. https://github.com/dart-lang/dartdoc/issues/4123

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4123 is the dartpad issue :(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, as I said, I noticed some were updated incorrectly when I did a find and replace. Just pushed a new commit

@Piinks Piinks requested a review from dkwingsmt July 1, 2026 22:29
@Piinks Piinks added the CICD Run CI/CD label Jul 1, 2026

@dkwingsmt dkwingsmt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 1, 2026
@auto-submit auto-submit Bot merged commit ab5051f into flutter:main Jul 1, 2026
89 checks passed
auto-submit Bot pushed a commit that referenced this pull request Jul 2, 2026
…12078)

Migrates @tool directives to @example in material_ui
Towards flutter/flutter#172936 and flutter/flutter#172937

Prerequisite:
* #12092, which moves missing sample files.

Related:
* #12063, which migrates `cupertino_ui`

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot 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.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
pull Bot pushed a commit to Klomgor/flutter that referenced this pull request Jul 2, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: cupertino_ui triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants