Repository navigation
docs: Document CupertinoSlidingSegmentedControl translucent unselected segments (#164073) - #186645
NadeemIqbal wants to merge 6 commits into
Conversation
…d segments The default backgroundColor (CupertinoColors.tertiarySystemFill) is translucent (alpha 0.12 in light mode), matching the native UISegmentedControl. This intentional behavior was not surfaced in the dartdoc, so users assumed it was a Flutter-side bug when content behind a segmented control showed through. Add a paragraph to the class-level dartdoc and clarify backgroundColor's description so the translucency is discoverable, and document how to obtain an opaque background (pass an opaque Color to backgroundColor). Fixes flutter#164073.
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for CupertinoSlidingSegmentedControl to clarify that the default backgroundColor is translucent, matching native iOS behavior. The review feedback identifies a violation of the Flutter style guide regarding the use of future tense in documentation and points out an inaccuracy where the documentation suggests a non-nullable property can be null.
| /// The default [backgroundColor], [CupertinoColors.tertiarySystemFill], is | ||
| /// intentionally translucent (alpha 0.12 in light mode) to match the native | ||
| /// `UISegmentedControl`. As a result, content placed behind the segmented | ||
| /// control — for example a [Stack] child beneath it — will show through the |
There was a problem hiding this comment.
According to the Flutter style guide, documentation should use the present tense and avoid "will". Additionally, "for example" is typically followed by a comma for better readability.
/// control — for example, a [Stack] child beneath it — shows through theReferences
- The Flutter style guide recommends using the present tense and avoiding 'will', 'shall', 'can', or 'may' in documentation. (link)
| /// [Color] is supplied here. | ||
| /// | ||
| /// The background will not be painted if null is specified. |
There was a problem hiding this comment.
The backgroundColor property is non-nullable (final Color), so it cannot be null. This statement is misleading and should be removed.
/// [Color] is supplied here.References
- Documentation should accurately reflect the API's constraints. Stating that a property can be null when it is non-nullable is misleading.
Address review feedback (flutter#186645): use present tense per the Flutter style guide ("shows through" instead of "will show through"), add the missing comma after "for example", and drop the misleading "if null" line on the non-nullable backgroundColor field.
| /// | ||
| /// The default [backgroundColor], [CupertinoColors.tertiarySystemFill], is | ||
| /// intentionally translucent (alpha 0.12 in light mode) to match the native | ||
| /// `UISegmentedControl`. As a result, content placed behind the segmented |
There was a problem hiding this comment.
| /// will not be painted if null is specified. | ||
| /// The default value is [CupertinoColors.tertiarySystemFill], which is | ||
| /// translucent (alpha 0.12 in light mode) to match the native | ||
| /// `UISegmentedControl`. Content placed behind the segmented control is |
…tedControl Address review feedback on flutter#186645: add the UISegmentedControl reference URL next to both mentions in the class-level dartdoc and the backgroundColor field doc, so readers can jump to Apple's documentation of the native control whose behavior the Flutter widget mirrors.
|
I've marked this PR as not ready to port to flutter/packages yet. |
|
This PR is ready to port to flutter/packages! 🥳 |
…idingSegmentedControl (#13178) Fixes flutter/flutter#164073 Ports flutter/flutter#186645. Part of flutter/flutter#188444. Documents that the default background of CupertinoSlidingSegmentedControl is translucent, so content behind unselected segments shows through unless an opaque color is passed. The original issue is flutter/flutter#164073. Tracking issue: flutter/flutter#188444. cc @NadeemIqbal Docs-only change, so this is test-exempt. I used AI assistance to port the approved documentation. ## 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.
|
Closing this PR because it has been ported to |
The default
CupertinoSlidingSegmentedControl.backgroundColorisCupertinoColors.tertiarySystemFill, which is translucent (alpha 0.12 in light mode) to match the nativeUISegmentedControl. The translucency was not documented, which led users to report it as a Flutter-side bug when content placed behind the control became visible through the unselected segments. Added a paragraph to the class-level dartdoc and to thebackgroundColordoc making the intentional translucency explicit and showing how to obtain an opaque background (pass an opaqueColortobackgroundColor). Triage on #164073 confirmed the behavior matches the native control.Fixes #164073.
Pre-launch Checklist
///).Documentation-only change, so I am claiming the test-exempt policy. Touches
packages/flutter/lib/src/cupertino/, which is currently under code freeze; needs theoverride code freezelabel to merge.