Skip to content

Commit 4dd0e3e

Browse files
authored
[cupertino_ui] Document translucent default background of CupertinoSlidingSegmentedControl (flutter#13178)
Fixes flutter#164073 Ports flutter#186645. Part of 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#164073. Tracking issue: 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.
1 parent 9d6cf9a commit 4dd0e3e

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎packages/cupertino_ui/lib/src/sliding_segmented_control.dart‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,15 @@ class _SegmentSeparatorState extends State<_SegmentSeparator>
339339
/// [thumbColor], [backgroundColor] arguments can be used to override the
340340
/// segmented control's colors from its defaults.
341341
///
342+
/// The default [backgroundColor], [CupertinoColors.tertiarySystemFill], is
343+
/// intentionally translucent (alpha 0.12 in light mode) to match the native
344+
/// `UISegmentedControl`
345+
/// (<https://developer.apple.com/documentation/uikit/uisegmentedcontrol>).
346+
/// As a result, content placed behind the segmented
347+
/// control — for example, a [Stack] child beneath it — shows through the
348+
/// unselected segments. To get an opaque background, pass an opaque [Color]
349+
/// to [backgroundColor].
350+
///
342351
/// <callout-box>
343352
///
344353
/// This example shows a [CupertinoSlidingSegmentedControl] with an enum type.
@@ -472,8 +481,13 @@ class CupertinoSlidingSegmentedControl<T extends Object> extends StatefulWidget
472481

473482
/// The color used to paint the rounded rect behind the [children] and the separators.
474483
///
475-
/// The default value is [CupertinoColors.tertiarySystemFill]. The background
476-
/// will not be painted if null is specified.
484+
/// The default value is [CupertinoColors.tertiarySystemFill], which is
485+
/// translucent (alpha 0.12 in light mode) to match the native
486+
/// `UISegmentedControl`
487+
/// (<https://developer.apple.com/documentation/uikit/uisegmentedcontrol>).
488+
/// Content placed behind the segmented control is
489+
/// therefore visible through the unselected segments unless an opaque
490+
/// [Color] is supplied here.
477491
final Color backgroundColor;
478492

479493
/// Determine whether segments have proportional widths based on their content.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
changelog: |
2+
- Documents that the default background of `CupertinoSlidingSegmentedControl` is translucent.
3+
version: patch

0 commit comments

Comments
 (0)