Skip to content

[palette_generator] An error in calculating titleTextColor and bodyTextColor for PaletteColor #31592

Closed
flutter/packages
#18

Description

@edwardez

First, I'm not very familiar with color theory so I might be wrong...

But I highly doubt that palette_generator is calculating titleTextColor and bodyTextColor for PaletteColor incorrectly.

As an example, in the test 'PaletteGenerator finds dominant color and text colors'.

Dominant color is 0xff0000ff while titleTextColor is 0xbc000000 and bodyTextColor is 0xda000000

The contrast ratio between text color and dominant color is extremely low, which doesn't seem correct.
https://contrast-ratio.com/#hsla%280%2C0%25%2C0%25%2C0.85%29-on-%230000ff

I think the problem is palette_generator converts Color to HSLColor then directly uses lightness in HSLColor. However it seems like relative luminance is different from lightness in HSLColor.

See line 687, 688 here
https://github.com/flutter/packages/blob/e40537243c1e07cbf47e1ffefc947c4092e34c28/packages/palette_generator/lib/palette_generator.dart#L687

Since it seems to be a easy fix I submitted a pr here :P
flutter/packages#18

Activity

  1. jonahwilliams commented on Apr 25, 2019

    @jonahwilliams
    Contributor
  2. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Jun 21, 2019
  3. github-actions commented on Aug 25, 2021

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

  4. locked as resolved and limited conversation to collaborators on Aug 25, 2021
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

    frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions