Skip to content

docs: Document CupertinoSlidingSegmentedControl translucent unselected segments (#164073) - #186645

Closed
NadeemIqbal wants to merge 6 commits into
flutter:masterfrom
NadeemIqbal:nadeem/164073-sliding-segmented-translucent-docs
Closed

NadeemIqbal wants to merge 6 commits into
flutter:masterfrom
NadeemIqbal:nadeem/164073-sliding-segmented-translucent-docs

Conversation

@NadeemIqbal

@NadeemIqbal NadeemIqbal commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

The default CupertinoSlidingSegmentedControl.backgroundColor is CupertinoColors.tertiarySystemFill, which is translucent (alpha 0.12 in light mode) to match the native UISegmentedControl. 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 the backgroundColor doc making the intentional translucency explicit and showing how to obtain an opaque background (pass an opaque Color to backgroundColor). 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 the override code freeze label to merge.

…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.
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: cupertino_ui cupertino_ui package in flutter/packages labels May 17, 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 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

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.

medium

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 the
References
  1. The Flutter style guide recommends using the present tense and avoiding 'will', 'shall', 'can', or 'may' in documentation. (link)

Comment on lines +475 to +477
/// [Color] is supplied here.
///
/// The background will not be painted if null is specified.

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.

medium

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
  1. 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.
@dkwingsmt
dkwingsmt requested a review from victorsanni May 20, 2026 18:34
victorsanni
victorsanni previously approved these changes May 21, 2026
///
/// 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

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.

/// 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

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.

and here too?

@victorsanni victorsanni added the CICD Run CI/CD label May 21, 2026
…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.
@dkwingsmt
dkwingsmt requested a review from victorsanni June 3, 2026 18:23
@Piinks Piinks added the Decoupling: Not ready to port yet Instructions will be provided when this is ready to move to flutter/packages. label Jun 24, 2026
@Piinks

Piinks commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

I've marked this PR as not ready to port to flutter/packages yet.
We'll provide instructions to move this change over to material_ui/cupertino_ui once ready to receive PRs. Thank you!

@dkwingsmt
dkwingsmt self-requested a review July 8, 2026 18:09
@dkwingsmt

Copy link
Copy Markdown
Contributor

This PR is ready to port to flutter/packages! 🥳
See guidance and instructions in #188444

@dkwingsmt dkwingsmt added Decoupling: Port to flutter/packages This PR is ready to be ported to flutter/packages. We will provide instructions to do so. and removed Decoupling: Not ready to port yet Instructions will be provided when this is ready to move to flutter/packages. labels Aug 25, 2026
@dkwingsmt
dkwingsmt marked this pull request as draft September 24, 2026 19:14
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 28, 2026
…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.
@dkwingsmt

Copy link
Copy Markdown
Contributor

Closing this PR because it has been ported to flutter/packages (which has been merged).

@dkwingsmt dkwingsmt closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Decoupling: Port to flutter/packages This PR is ready to be ported to flutter/packages. We will provide instructions to do so. framework flutter/packages/flutter repository. See also f: labels. p: cupertino_ui cupertino_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clearly document that CupertinoSlidingSegmentedControl's unselected segments are translucent

4 participants