Skip to content

[Cupertino] Default primaryContrastingColor is incorrect in dark mode #152846

Closed

Description

@kerberjg

Steps to reproduce

  1. Create a CupertinoApp without overriding the theme
  2. Inside of it create a CupertinoButton that displays some text, again without overriding any themes or colors

Expected results

The default primaryContrastColor should be CupertinoColors.white, which always resolves to white regardless of platform brightness

Actual results

The default primaryContrastColor is CupertinoColors.systemBackground, which resolves to black(-ish) in dark mode, which is incorrect.

Code sample

Code sample
import 'package:flutter/cupertino.dart';

void main() =>
  runApp(
    CupertinoApp(
      home: Center(
        child: CupertinoButton.filled(
          onPressed: () {},
          child: Text("Text"),
        )
      )
    ),
  );

Screenshots or Video

Screenshots / Video demonstration

See example (above: iOS HIG, below: Flutter)
image

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
    • Flutter version 3.22.2 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (9 weeks ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[!] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    ✗ Unable to get list of installed Simulator runtimes.
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.91.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (4 available)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 3 categories.

Activity

  1. danagbemava-nc commented on Aug 5, 2024

    @danagbemava-nc
    Member

    Reproducible using the code sample provided above.

    flutter doctor -v
    [!] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale en-GB)
        • Flutter version 3.22.3 on channel stable at /Users/nexus/dev/sdks/flutter
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision b0850beeb2 (3 weeks ago), 2024-07-16 21:43:41 -0700
        • Engine revision 235db911ba
        • Dart version 3.4.4
        • DevTools version 2.34.3
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Flutter (Channel master, 3.24.0-1.0.pre.438, on macOS 14.5 23F79 darwin-arm64, locale en-GB)
        • Flutter version 3.24.0-1.0.pre.438 on channel master at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision cbfb222446 (33 hours ago), 2024-08-03 21:13:39 -0400
        • Engine revision 16012e2f8c
        • Dart version 3.6.0 (build 3.6.0-114.0.dev)
        • DevTools version 2.38.0
    
    
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: fidelityMatching the OEM platforms better
    p: cupertino_uicupertino_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Aug 5, 2024
  3. kerberjg commented on Aug 7, 2024

    @kerberjg
    ContributorAuthor

    I've also investigated the possibility of using iOS' UIColor lightText, but that didn't seem to look correct either (screenshot below).

    I'd like to confirm that the default primaryContrastingColor is CupertinoColors.white. I'll submit a PR fixing that

    UIColor lightText
    image

  4. added a commit that references this issue on Aug 7, 2024
    a3cd896
  5. kerberjg commented on Aug 7, 2024

    @kerberjg
    ContributorAuthor

    PR has been submitted, pending review

  6. added a commit that references this issue on Aug 7, 2024
    c288594
  7. added a commit that references this issue on Aug 7, 2024
    dc4d64c
  8. added 2 commits that reference this issue on Aug 16, 2024
    78e2cc7
    2756a4f
  9. github-actions commented on Aug 23, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  10. locked as resolved and limited conversation to collaborators on Aug 23, 2024
  11. added a commit that references this issue on Sep 2, 2024
    e8e1b89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: fidelityMatching the OEM platforms betterfound in release: 3.22Found to occur in 3.22found in release: 3.24Found to occur in 3.24frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cupertino_uicupertino_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions